Show / Hide Table of Contents

Class DirectedDynamicGraphExtensions

Contains contraction related extension methods related to the directed dynamic graph.

Inheritance
System.Object
DirectedDynamicGraphExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: System.Dynamic.ExpandoObject
Assembly: cs.temp.dll.dll
Syntax
public static class DirectedDynamicGraphExtensions
Remarks

Edge definition of an edge-based dynamic graph:

  • Original edge : [0] FIXED weight.
  • Contracted edges
  • no sequences : [0] FIXED weight. [0] DYN contracted id.
  • sequences : [0] FIXED weight. [0] DYN contracted id. [1] DYN size [2] DYN seq1.0 (assuming size = 1) [3] DYN seq2.0 (starts at this location assuming size = 1)

Sequences are always added in the corresponding edge-direction:

  • source seq: {source} -> seq1.0 -> seq1.0 -> ...
  • target seq: ... -> seq2.0 -> seq2.1 -> {target}

Methods

AddEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>)

Adds an edge.

Declaration
public static uint AddEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

System.Single weight

System.Nullable<System.Boolean> direction

Returns
System.UInt32

AddEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>, Nullable<UInt32>, UInt32[], UInt32[])

Adds a contracted edge including sequences.

Declaration
public static uint AddEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction, uint ? contractedId, uint[] sequence1, uint[] sequence2)
Parameters
DirectedDynamicGraph graph

The graph.

System.UInt32 vertex1

The start vertex.

System.UInt32 vertex2

The end vertex.

System.Single weight

The weight.

System.Nullable<System.Boolean> direction

The direction.

System.Nullable<System.UInt32> contractedId

The vertex being shortcutted.

System.UInt32[] sequence1

The relevant sequence starting but not including vertex1; vertex1->(0->1...).

System.UInt32[] sequence2

The relevant sequence starting but not including vertex2; (0->1...)->vertex2.

Returns
System.UInt32

AddEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>, Single, Single)

Adds an edge.

Declaration
public static uint AddEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction, float distance, float time)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

System.Single weight

System.Nullable<System.Boolean> direction

System.Single distance

System.Single time

Returns
System.UInt32

AddEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>, UInt32, Single, Single, UInt32[], UInt32[])

Adds a contracted edge including sequences.

Declaration
public static uint AddEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction, uint contractedId, float distance, float time, uint[] sequence1, uint[] sequence2)
Parameters
DirectedDynamicGraph graph

The graph.

System.UInt32 vertex1

The start vertex.

System.UInt32 vertex2

The end vertex.

System.Single weight

The weight.

System.Nullable<System.Boolean> direction

The direction.

System.UInt32 contractedId

The vertex being shortcutted.

System.Single distance

The distance.

System.Single time

The time.

System.UInt32[] sequence1

The relevant sequence starting but not including vertex1; vertex1->(0->1...).

System.UInt32[] sequence2

The relevant sequence starting but not including vertex2; (0->1...)->vertex2.

Returns
System.UInt32

AddEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>, UInt32, UInt32[], UInt32[])

Adds a contracted edge including sequences.

Declaration
public static uint AddEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction, uint contractedId, uint[] sequence1, uint[] sequence2)
Parameters
DirectedDynamicGraph graph

The graph.

System.UInt32 vertex1

The start vertex.

System.UInt32 vertex2

The end vertex.

System.Single weight

The weight.

System.Nullable<System.Boolean> direction

The direction.

System.UInt32 contractedId

The vertex being shortcutted.

System.UInt32[] sequence1

The relevant sequence starting but not including vertex1; vertex1->(0->1...).

System.UInt32[] sequence2

The relevant sequence starting but not including vertex2; (0->1...)->vertex2.

Returns
System.UInt32

AddOrUpdateEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>, UInt32, Single, Single, UInt32[], UInt32[])

Add or update edge.

Declaration
public static void AddOrUpdateEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction, uint contractedId, float distance, float time, uint[] s1, uint[] s2)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

System.Single weight

System.Nullable<System.Boolean> direction

System.UInt32 contractedId

System.Single distance

System.Single time

System.UInt32[] s1

System.UInt32[] s2

AddOrUpdateEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>, UInt32, UInt32[], UInt32[])

Add or update edge.

Declaration
public static void AddOrUpdateEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction, uint contractedId, uint[] s1, uint[] s2)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

System.Single weight

System.Nullable<System.Boolean> direction

System.UInt32 contractedId

System.UInt32[] s1

System.UInt32[] s2

BuildPath(DirectedDynamicGraph, UInt32[], Boolean, Boolean)

Builds a path along the sequence of vertices that can be followed using original edges.

Declaration
public static EdgePath<float> BuildPath(this DirectedDynamicGraph graph, uint[] originalPath, bool reverse = false, bool pathIsBackwards = false)
Parameters
DirectedDynamicGraph graph

The graph.

System.UInt32[] originalPath

The sequence."

System.Boolean reverse

The sequence has to be used in reverse, for performance reasons to avoid creating another array.

System.Boolean pathIsBackwards

When the resulting path is a backwards path agains the direction of the direction flags.

Returns
EdgePath<System.Single>

BuildPath(DirectedDynamicGraph.EdgeEnumerator, UInt32[], Boolean, Boolean)

Builds a path along the sequence of vertices that can be followed using original edges.

Declaration
public static EdgePath<float> BuildPath(this DirectedDynamicGraph.EdgeEnumerator enumerator, uint[] originalPath, bool reverse = false, bool pathIsBackwards = false)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

The enumerator.

System.UInt32[] originalPath

The sequence."

System.Boolean reverse

The sequence has to be used in reverse, for performance reasons to avoid creating another array.

System.Boolean pathIsBackwards

When the resulting path is a backwards path agains the direction of the direction flags.

Returns
EdgePath<System.Single>

Direction(DirectedDynamicGraph.EdgeEnumerator)

Gets the direction.

Declaration
public static bool ? Direction(this DirectedDynamicGraph.EdgeEnumerator enumerator)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

Returns
System.Nullable<System.Boolean>

ExpandEdge(DirectedDynamicGraph, UInt32, UInt32, List<UInt32>, Boolean, Boolean)

Expands a the shortest edge between the two given vertices.

Declaration
public static void ExpandEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, List<uint> vertices, bool inverted, bool forward)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

List<System.UInt32> vertices

System.Boolean inverted

System.Boolean forward

GetContracted(DirectedDynamicGraph.EdgeEnumerator)

Gets the contracted id, returns null if this edge is not a shortcut.

Declaration
public static uint ? GetContracted(this DirectedDynamicGraph.EdgeEnumerator edge)
Parameters
DirectedDynamicGraph.EdgeEnumerator edge

Returns
System.Nullable<System.UInt32>

GetContracted(DynamicEdge)

Gets the contracted id, returns null if this edge is not a shortcut.

Declaration
public static uint ? GetContracted(this DynamicEdge edge)
Parameters
DynamicEdge edge

Returns
System.Nullable<System.UInt32>

GetEdges(DirectedDynamicGraph, UInt32)

Gets all edges starting at this edges.

Declaration
public static List<DynamicEdge> GetEdges(this DirectedDynamicGraph graph, uint vertex)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex

Returns
List<DynamicEdge>

GetOriginal(DirectedDynamicGraph, UInt32, UInt32)

Gets the original edge.

Declaration
public static DynamicEdge GetOriginal(this DirectedDynamicGraph graph, uint vertex1, uint vertex2)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

Returns
DynamicEdge

GetOriginal(DirectedDynamicGraph.EdgeEnumerator, UInt32, UInt32)

Gets the original edge.

Declaration
public static DynamicEdge GetOriginal(this DirectedDynamicGraph.EdgeEnumerator enumerator, uint vertex1, uint vertex2)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

System.UInt32 vertex1

System.UInt32 vertex2

Returns
DynamicEdge

GetOriginalWeight(DirectedDynamicGraph, UInt32, UInt32)

Gets the best original weight between the two given vertices.

Declaration
public static float GetOriginalWeight(this DirectedDynamicGraph graph, uint vertex1, uint vertex2)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

Returns
System.Single

GetOriginalWeight(DirectedDynamicGraph, UInt32[])

Gets the weight for the given original sequence.

Declaration
public static float GetOriginalWeight(this DirectedDynamicGraph graph, uint[] sequence)
Parameters
DirectedDynamicGraph graph

System.UInt32[] sequence

Returns
System.Single

GetSequence1(DirectedDynamicGraph.EdgeEnumerator)

Gets the sequence at the source.

Declaration
public static uint[] GetSequence1(this DirectedDynamicGraph.EdgeEnumerator edge)
Parameters
DirectedDynamicGraph.EdgeEnumerator edge

Returns
System.UInt32[]

GetSequence1(DirectedDynamicGraph.EdgeEnumerator, ref UInt32[])

Gets the sequence at the source.

Declaration
public static int GetSequence1(this DirectedDynamicGraph.EdgeEnumerator edge, ref uint[] sequence1)
Parameters
DirectedDynamicGraph.EdgeEnumerator edge

System.UInt32[] sequence1

Returns
System.Int32

The number of elements in the array that represent the sequence.

GetSequence1(DynamicEdge)

Gets the sequence at the source.

Declaration
public static uint[] GetSequence1(this DynamicEdge edge)
Parameters
DynamicEdge edge

Returns
System.UInt32[]

GetSequence2(DirectedDynamicGraph.EdgeEnumerator)

Gets the sequence at the target.

Declaration
public static uint[] GetSequence2(this DirectedDynamicGraph.EdgeEnumerator edge)
Parameters
DirectedDynamicGraph.EdgeEnumerator edge

Returns
System.UInt32[]

GetSequence2(DynamicEdge)

Gets the sequence at the target.

Declaration
public static uint[] GetSequence2(this DynamicEdge edge)
Parameters
DynamicEdge edge

Returns
System.UInt32[]

GetShortestEdge(DirectedDynamicGraph, UInt32, UInt32, Func<UInt32[], Nullable<Single>>)

Gets the shortest edge between two vertices.

Declaration
public static DynamicEdge GetShortestEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, Func<uint[], float ? > getWeight)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

Func<System.UInt32[], System.Nullable<System.Single>> getWeight

Returns
DynamicEdge

IdDirected(DirectedDynamicGraph.EdgeEnumerator)

Returns a directed version of the edge-id. Smaller than 0 if inverted, as-is if not inverted.

Declaration
public static long IdDirected(this DirectedDynamicGraph.EdgeEnumerator enumerator)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

Returns
System.Int64

Remarks

The relationship between a regular edge id and a directed edge id:

  • 0 -> 1 forward, -1 backward.
  • all other id's are offset by 1 and postive when forward, negative when backward.

IdDirected(DynamicEdge)

Returns a directed version of the edge-id. Smaller than 0 if inverted, as-is if not inverted.

Declaration
public static long IdDirected(this DynamicEdge edge)
Parameters
DynamicEdge edge

Returns
System.Int64

Remarks

The relationship between a regular edge id and a directed edge id:

  • 0 -> 1 forward, -1 backward.
  • all other id's are offset by 1 and postive when forward, negative when backward.

IsOriginal(DirectedDynamicGraph.EdgeEnumerator)

Returns true if this edge is an original edge, not a shortcut.

Declaration
public static bool IsOriginal(this DirectedDynamicGraph.EdgeEnumerator edge)
Parameters
DirectedDynamicGraph.EdgeEnumerator edge

Returns
System.Boolean

IsOriginal(DynamicEdge)

Returns true if this edge is an original edge, not a shortcut.

Declaration
public static bool IsOriginal(this DynamicEdge edge)
Parameters
DynamicEdge edge

Returns
System.Boolean

MoveToEdge(DirectedDynamicGraph.EdgeEnumerator, Int64)

Moves to the given directed edge-id.

Declaration
public static void MoveToEdge(this DirectedDynamicGraph.EdgeEnumerator enumerator, long directedEdgeId)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

System.Int64 directedEdgeId

MoveToEdge<T>(DirectedDynamicGraph.EdgeEnumerator, UInt32, UInt32, UInt32[], WeightHandler<T>, Boolean, out T)

Moves this enumerator to an edge (vertex1->vertex2) that has an end sequence that matches the given sequence.

Declaration
public static bool MoveToEdge<T>(this DirectedDynamicGraph.EdgeEnumerator enumerator, uint vertex1, uint vertex2, uint[] sequence2, WeightHandler<T> weightHandler, bool direction, out T weight)where T : struct
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

System.UInt32 vertex1

System.UInt32 vertex2

System.UInt32[] sequence2

WeightHandler<T> weightHandler

System.Boolean direction

T weight

Returns
System.Boolean

Type Parameters
T

MoveToOriginal(DirectedDynamicGraph.EdgeEnumerator, UInt32, UInt32)

Moves the enumerator to the edge representing the original edge between the two given vertices that can form a path from vertex1 -> vertex2. When returned true, the edge is vertex1 -> vertex2 when false vertex2 -> vertex1.

Declaration
public static bool MoveToOriginal(this DirectedDynamicGraph.EdgeEnumerator enumerator, uint vertex1, uint vertex2)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

System.UInt32 vertex1

System.UInt32 vertex2

Returns
System.Boolean

MoveToTargetVertex(DirectedDynamicGraph.EdgeEnumerator, UInt32)

Moves the enumerator to the target vertex of the given edge id.

Declaration
public static bool MoveToTargetVertex(this DirectedDynamicGraph.EdgeEnumerator enumerator, uint edgeId)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

System.UInt32 edgeId

Returns
System.Boolean

TryAddOrUpdateEdge(DirectedDynamicGraph, UInt32, UInt32, Single, Nullable<Boolean>, UInt32, out Int32, out Int32)

Tries adding or updating an edge and returns #added and #removed edges.

Declaration
public static void TryAddOrUpdateEdge(this DirectedDynamicGraph graph, uint vertex1, uint vertex2, float weight, bool ? direction, uint contractedId, out int added, out int removed)
Parameters
DirectedDynamicGraph graph

System.UInt32 vertex1

System.UInt32 vertex2

System.Single weight

System.Nullable<System.Boolean> direction

System.UInt32 contractedId

System.Int32 added

System.Int32 removed

Weight(DirectedDynamicGraph.EdgeEnumerator)

Gets the weight.

Declaration
public static float Weight(this DirectedDynamicGraph.EdgeEnumerator enumerator)
Parameters
DirectedDynamicGraph.EdgeEnumerator enumerator

Returns
System.Single

Back to top Built by Itinero, MIT licensed.