Show / Hide Table of Contents

Class EdgeExtensions

Extensions related to graph edges.

Inheritance
System.Object
EdgeExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: QuikGraph
Assembly: QuikGraph.dll
Syntax
public static class EdgeExtensions

Methods

| Improve this Doc View Source

GetOtherVertex<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 edge.

Returns
Type Description
TVertex

The other edge vertex.

Type Parameters
Name Description
TVertex

Vertex type.

Exceptions
Type Condition
System.ArgumentNullException

edge is null.

System.ArgumentNullException

vertex is null.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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

path is null.

| Improve this Doc View Source

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 edge vertex.

Returns
Type Description
System.Boolean

True if the vertex is adjacent to this edge, false otherwise.

Type Parameters
Name Description
TVertex

Vertex type.

Exceptions
Type Condition
System.ArgumentNullException

edge is null.

System.ArgumentNullException

vertex is null.

| Improve this Doc View Source

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

path is null.

| Improve this Doc View Source

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

path is null.

| Improve this Doc View Source

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 root is a predecessor of the vertex.

Type Parameters
Name Description
TVertex

Vertex type.

TEdge

Edge type.

Exceptions
Type Condition
System.ArgumentNullException

predecessors is null.

System.ArgumentNullException

root is null.

System.ArgumentNullException

vertex is null.

| Improve this Doc View Source

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

edge is null.

| Improve this Doc View Source

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

edges is null.

| Improve this Doc View Source

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 source and target match edge vertices, false otherwise.

Type Parameters
Name Description
TVertex

Vertex type.

Exceptions
Type Condition
System.ArgumentNullException

edge is null.

System.ArgumentNullException

source is null.

System.ArgumentNullException

target is null.

| Improve this Doc View Source

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>

A SEquatableEdge<TVertex>.

Type Parameters
Name Description
TVertex

Vertex type.

Exceptions
Type Condition
System.ArgumentNullException

edge is null.

| Improve this Doc View Source

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

predecessors is null.

System.ArgumentNullException

vertex is null.

| Improve this Doc View Source

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 source and target match edge vertices, false otherwise.

Type Parameters
Name Description
TVertex

Vertex type.

Exceptions
Type Condition
System.ArgumentNullException

edge is null.

System.ArgumentNullException

source is null.

System.ArgumentNullException

target is null.

  • Improve this Doc
  • View Source
In This Article
Back to top QuikGraph