Class EdgeExtensions
Extensions related to graph edges.
Inheritance
Inherited Members
Namespace: QuikGraph
Assembly: QuikGraph.dll
Syntax
public static class EdgeExtensions
Methods
| Improve this Doc View SourceGetOtherVertex<TVertex>(IEdge<TVertex>, TVertex)
Given a vertex
, returns the other vertex in the edge.
Declaration
public static TVertex GetOtherVertex<TVertex>(this IEdge<TVertex> edge, TVertex vertex)
Parameters
Type | Name | Description |
---|---|---|
IEdge<TVertex> | edge | The edge. |
TVertex | vertex | The source or target vertex of the |
Returns
Type | Description |
---|---|
TVertex | The other edge vertex. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
GetUndirectedVertexEquality<TVertex, TEdge>()
Returns the most efficient comparer for the particular type of TEdge
.
If TEdge
implements IUndirectedEdge<TVertex>, then only
the (source, target) pair has to be compared; if not, (source, target) and (target, source)
have to be compared.
Declaration
public static EdgeEqualityComparer<TVertex> GetUndirectedVertexEquality<TVertex, TEdge>()
Returns
Type | Description |
---|---|
EdgeEqualityComparer<TVertex> | The best edge equality comparer. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
HasCycles<TVertex, TEdge>(IEnumerable<TEdge>)
Checks if this sequence of edges makes a cycle.
Declaration
public static bool HasCycles<TVertex, TEdge>(this IEnumerable<TEdge> path)
where TEdge : IEdge<TVertex>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TEdge> | path | Sequence of edges that forms a path. |
Returns
Type | Description |
---|---|
System.Boolean | True if the set makes a cycle, false otherwise. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
Remarks
Note that this function only work when given a path.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
IsAdjacent<TVertex>(IEdge<TVertex>, TVertex)
Gets a value indicating if the vertex
is adjacent to the
edge
(is the source or target).
Declaration
public static bool IsAdjacent<TVertex>(this IEdge<TVertex> edge, TVertex vertex)
Parameters
Type | Name | Description |
---|---|---|
IEdge<TVertex> | edge | The edge. |
TVertex | vertex | Source or target |
Returns
Type | Description |
---|---|
System.Boolean | True if the |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
IsPath<TVertex, TEdge>(IEnumerable<TEdge>)
Checks if this sequence of edges makes a path.
Declaration
public static bool IsPath<TVertex, TEdge>(this IEnumerable<TEdge> path)
where TEdge : IEdge<TVertex>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TEdge> | path | Sequence of edges. |
Returns
Type | Description |
---|---|
System.Boolean | True if the set makes a complete path, false otherwise. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
IsPathWithoutCycles<TVertex, TEdge>(IEnumerable<TEdge>)
Checks if this path of edges does not make a cycle.
Declaration
public static bool IsPathWithoutCycles<TVertex, TEdge>(this IEnumerable<TEdge> path)
where TEdge : IEdge<TVertex>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TEdge> | path | Path of edges. |
Returns
Type | Description |
---|---|
System.Boolean | True if the path makes a cycle, false otherwise. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
IsPredecessor<TVertex, TEdge>(IDictionary<TVertex, TEdge>, TVertex, TVertex)
Checks that the root
is a predecessor of the given vertex
.
Declaration
public static bool IsPredecessor<TVertex, TEdge>(this IDictionary<TVertex, TEdge> predecessors, TVertex root, TVertex vertex)
where TEdge : IEdge<TVertex>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<TVertex, TEdge> | predecessors | Predecessors map. |
TVertex | root | Root vertex. |
TVertex | vertex | Ending vertex. |
Returns
Type | Description |
---|---|
System.Boolean | True if the |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
IsSelfEdge<TVertex>(IEdge<TVertex>)
Gets a value indicating if the edge is a self edge.
Declaration
public static bool IsSelfEdge<TVertex>(this IEdge<TVertex> edge)
Parameters
Type | Name | Description |
---|---|---|
IEdge<TVertex> | edge | Edge to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if edge is a self one, false otherwise. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
ReverseEdges<TVertex, TEdge>(IEnumerable<TEdge>)
Returns an enumeration of reversed edges.
Declaration
public static IEnumerable<SReversedEdge<TVertex, TEdge>> ReverseEdges<TVertex, TEdge>(IEnumerable<TEdge> edges)
where TEdge : IEdge<TVertex>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TEdge> | edges | Edges to reversed. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SReversedEdge<TVertex, TEdge>> | Reversed edges. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
SortedVertexEquality<TVertex>(IEdge<TVertex>, TVertex, TVertex)
Gets a value indicating if the vertices of this edge match
source
and target
vertices.
Declaration
public static bool SortedVertexEquality<TVertex>(this IEdge<TVertex> edge, TVertex source, TVertex target)
Parameters
Type | Name | Description |
---|---|---|
IEdge<TVertex> | edge | The edge. |
TVertex | source | Source vertex. |
TVertex | target | Target vertex. |
Returns
Type | Description |
---|---|
System.Boolean | True if both |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
ToVertexPair<TVertex>(IEdge<TVertex>)
Creates a vertex pair (source, target) from this edge.
Declaration
public static SEquatableEdge<TVertex> ToVertexPair<TVertex>(this IEdge<TVertex> edge)
Parameters
Type | Name | Description |
---|---|---|
IEdge<TVertex> | edge | The edge. |
Returns
Type | Description |
---|---|
SEquatableEdge<TVertex> |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
TryGetPath<TVertex, TEdge>(IDictionary<TVertex, TEdge>, TVertex, out IEnumerable<TEdge>)
Tries to get the predecessor path, if reachable.
Declaration
public static bool TryGetPath<TVertex, TEdge>(this IDictionary<TVertex, TEdge> predecessors, TVertex vertex, out IEnumerable<TEdge> path)
where TEdge : IEdge<TVertex>
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IDictionary<TVertex, TEdge> | predecessors | Predecessors map. |
TVertex | vertex | Path ending vertex. |
System.Collections.Generic.IEnumerable<TEdge> | path | Path to the ending vertex. |
Returns
Type | Description |
---|---|
System.Boolean | True if a path was found, false otherwise. |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
TEdge | Edge type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
UndirectedVertexEquality<TVertex>(IEdge<TVertex>, TVertex, TVertex)
Gets a value indicating if the vertices of this edge match
source
and target
or target
and source
vertices.
Declaration
public static bool UndirectedVertexEquality<TVertex>(this IEdge<TVertex> edge, TVertex source, TVertex target)
Parameters
Type | Name | Description |
---|---|---|
IEdge<TVertex> | edge | The edge. |
TVertex | source | Source vertex. |
TVertex | target | Target vertex. |
Returns
Type | Description |
---|---|
System.Boolean | True if both |
Type Parameters
Name | Description |
---|---|
TVertex | Vertex type. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
System.ArgumentNullException |
|