Skip to content
Alexandre Rabérin edited this page Oct 24, 2021 · 3 revisions

Edges (directed edge)

While a vertex could be any type with QuikGraph, the edge type must implement IEdge<TVertex> (and comply to it's contract). QuikGraph comes with various default implementations:

  • Classes
    • Edge<TVertex>, a vanilla implementation,
    • EquatableEdge<TVertex>, implements IEquatable<EquatableEdge<TVertex>> on Source and Target,
    • TaggedEdge<TVertex, TTag>, it's an Edge<TVertex> that also holds an additional tag information,
    • EquatableTaggedEdge<TVertex, TTag>, it's an EquatableEdge<TVertex> that also holds an additional tag information,
  • Structures
    • SEdge<TVertex>, an immutable edge,
    • SEquatableEdge<TVertex>, implements IEquatable<SEquatableEdge<TVertex>> on Source and Target,
    • STaggedEdge<TVertex, TTag>, edge that also holds an additional tag information,
    • SEquatableTaggedEdge<TVertex, TTag>, equatable edge that also holds an additional tag information,
    • SReversedEdge<TVertex, TEdge>, implementation that is reversing an edge Source and Target,

The struct based edge will provide better performance and should be used when you do not plan to use custom edges.

Tagged edges implement ITagged<TTag>, a tag is basically an additional information put on an edge and can represent anything (for example a cost associated to the edge, etc).

Of course, you can always implement your own version IEdge<TVertex> that will better fit your needs.

Undirected edges

In undirected graphs, the order of the source or target vertices should not matter. In order to improve efficiency, edges that implement the IUndirectedEdge<TVertex> interface must sort the vertices so that Source <= Target (with respect to the default Comparer). This provides some performance gains in various data structures and algorithms.

  • Classes
    • UndirectedEdge<TVertex>, an vanilla implementation,
    • TaggedUndirectedEdge<TVertex, TTag>, it's an UndirectedEdge<TVertex> that also holds an additional tag information,
  • Structures
    • SUndirectedEdge<TVertex>, an immutable edge,
    • STaggedUndirectedEdge<TVertex, TTag>, undirected edge that also holds an additional tag information
Clone this wiki locally