Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
tuples
Browse files Browse the repository at this point in the history
  • Loading branch information
sbromberger committed Mar 10, 2017
1 parent f29e87a commit 42daf7c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ abstract type AbstractPathState end
_insert_and_dedup!(v::Vector{Int}, x::Int) = isempty(splice!(v, searchsorted(v,x), x))

"""A type representing a single edge between two vertices of a graph."""
abstract AbstractEdge
abstract type AbstractEdge end

struct Edge <: AbstractEdge
src::Int
dst::Int
Expand All @@ -18,7 +19,7 @@ src(e::Edge) = e.src
dst(e::Edge) = e.dst

convert(::Type{Pair}, e::Edge) = Pair(src(e), dst(e))
convert(::Type{Tuple}, e::Edge) = (src(e), dst(e))
Tuple(e::Edge) = (e.src, e.dst)

reverse(e::Edge) = Edge(dst(e), src(e))
is_ordered(e::Edge) = src(e) <= dst(e)
Expand Down

0 comments on commit 42daf7c

Please sign in to comment.