Satsuma
a delicious .NET graph library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Pages
Public Member Functions | Properties | List of all members
Satsuma.Path Class Reference

Adaptor for storing a path of an underlying graph. More...

Inheritance diagram for Satsuma.Path:
Satsuma.IPath Satsuma.IClearable Satsuma.IGraph Satsuma.IArcLookup

Public Member Functions

void AddFirst (Arc arc)
 Appends an arc to the start of the path. More...
 
void AddLast (Arc arc)
 Appends an arc to the end of the path. More...
 
int ArcCount (ArcFilter filter=ArcFilter.All)
 Returns the total number of arcs satisfying a given filter. More...
 
int ArcCount (Node u, ArcFilter filter=ArcFilter.All)
 Returns the number of arcs adjacent to a specific node satisfying a given filter. More...
 
int ArcCount (Node u, Node v, ArcFilter filter=ArcFilter.All)
 Returns the number of arcs adjacent to two nodes satisfying a given filter. More...
 
IEnumerable< ArcArcs (ArcFilter filter=ArcFilter.All)
 
IEnumerable< ArcArcs (Node u, ArcFilter filter=ArcFilter.All)
 
IEnumerable< ArcArcs (Node u, Node v, ArcFilter filter=ArcFilter.All)
 
void Begin (Node node)
 Makes a one-node path from an empty path. More...
 
void Clear ()
 Resets the path to an empty path. More...
 
bool HasArc (Arc arc)
 Returns whether the given arc is contained in the graph. More...
 
bool HasNode (Node node)
 Returns whether the given node is contained in the graph. More...
 
bool IsEdge (Arc arc)
 Returns whether the arc is undirected (true) or directed (false). More...
 
Arc NextArc (Node node)
 Returns the arc connecting a node with its successor in the path. More...
 
int NodeCount ()
 Returns the total number of nodes in O(1) time. More...
 
IEnumerable< NodeNodes ()
 Returns all nodes of the graph. More...
 
 Path (IGraph graph)
 Initializes an empty path. More...
 
Arc PrevArc (Node node)
 Returns the arc connecting a node with its predecessor in the path. More...
 
void Reverse ()
 Reverses the path in O(1) time. More...
 
Node U (Arc arc)
 Returns the first node of an arc. Directed arcs point from U to V. More...
 
Node V (Arc arc)
 Returns the second node of an arc. Directed arcs point from U to V. More...
 

Properties

Node FirstNode [get, set]
 
IGraph Graph [get, set]
 The graph containing the path. More...
 
Node LastNode [get, set]
 

Detailed Description

Adaptor for storing a path of an underlying graph.

The Node and Arc set of the adaptor is a subset of that of the original graph. The underlying graph can be modified while using this adaptor, as long as no path nodes and path arcs are deleted.

Example (building a path):

var g = new CompleteGraph(15);
var p = new Path(g);
var u = g.GetNode(0), v = g.GetNode(1), w = g.GetNode(2);
p.Begin(u);
p.AddLast(g.GetArc(u, v));
p.AddFirst(g.GetArc(w, u));
// now we have the w--u--v path
p.Reverse();
// now we have the v--u--w path
See Also
PathGraph

Definition at line 109 of file Path.cs.

Constructor & Destructor Documentation

Satsuma.Path.Path ( IGraph  graph)

Initializes an empty path.

Definition at line 123 of file Path.cs.

Member Function Documentation

void Satsuma.Path.AddFirst ( Arc  arc)

Appends an arc to the start of the path.

Parameters
arcAn arc connecting FirstNode either with LastNode or with a node not yet on the path. The arc may point in any direction.
Exceptions
ArgumentExceptionThe arc is not valid or the path is a cycle.

Definition at line 162 of file Path.cs.

void Satsuma.Path.AddLast ( Arc  arc)

Appends an arc to the end of the path.

Parameters
arcAn arc connecting LastNode either with FirstNode or with a node not yet on the path. The arc may point in any direction.
Exceptions
ArgumentExceptionThe arc is not valid or the path is a cycle.

Definition at line 185 of file Path.cs.

int Satsuma.Path.ArcCount ( ArcFilter  filter = ArcFilter.All)

Returns the total number of arcs satisfying a given filter.

Parameters
filterDetailed description: see Arcs(ArcFilter).

Implements Satsuma.IGraph.

Definition at line 275 of file Path.cs.

int Satsuma.Path.ArcCount ( Node  u,
ArcFilter  filter = ArcFilter.All 
)

Returns the number of arcs adjacent to a specific node satisfying a given filter.

Parameters
filterDetailed description: see Arcs(Node, ArcFilter).

Implements Satsuma.IGraph.

Definition at line 280 of file Path.cs.

int Satsuma.Path.ArcCount ( Node  u,
Node  v,
ArcFilter  filter = ArcFilter.All 
)

Returns the number of arcs adjacent to two nodes satisfying a given filter.

Parameters
filterDetailed description: see Arcs(Node, Node, ArcFilter).

Implements Satsuma.IGraph.

Definition at line 285 of file Path.cs.

IEnumerable<Arc> Satsuma.Path.Arcs ( ArcFilter  filter = ArcFilter.All)

Returns all arcs of the graph satisfying a given filter.

Parameters
filterCannot be ArcType.Forward/ArcType.Backward.
  • If ArcFilter.All, then all arcs are returned.
  • If ArcFilter.Edge, only the edges (undirected arcs) are returned.

Implements Satsuma.IGraph.

Definition at line 253 of file Path.cs.

IEnumerable<Arc> Satsuma.Path.Arcs ( Node  u,
ArcFilter  filter = ArcFilter.All 
)

Returns all arcs adjacent to a specific node satisfying a given filter.

Parameters
filter
  • If ArcFilter.All, then all arcs are returned.
  • If ArcFilter.Edge, only the edges (undirected arcs) are returned.
  • If ArcFilter.Forward, only the arcs exiting u (this includes edges) are returned.
  • If ArcFilter.Backward, only the arcs entering u (this includes edges) are returned.

Implements Satsuma.IGraph.

Definition at line 260 of file Path.cs.

IEnumerable<Arc> Satsuma.Path.Arcs ( Node  u,
Node  v,
ArcFilter  filter = ArcFilter.All 
)

Returns all arcs adjacent to two nodes satisfying a given filter.

Parameters
filter
  • If ArcFilter.All, then all arcs are returned.
  • If ArcFilter.Edge, only the edges (undirected arcs) are returned.
  • If ArcFilter.Forward, only the arcs from u to v (this includes edges) are returned.
  • If ArcFilter.Backward, only the arcs from v to u (this includes edges) are returned.

Implements Satsuma.IGraph.

Definition at line 265 of file Path.cs.

void Satsuma.Path.Begin ( Node  node)

Makes a one-node path from an empty path.

Exceptions
InvalidOperationExceptionThe path is not empty.

Definition at line 149 of file Path.cs.

void Satsuma.Path.Clear ( )

Resets the path to an empty path.

Implements Satsuma.IClearable.

Definition at line 135 of file Path.cs.

bool Satsuma.Path.HasArc ( Arc  arc)

Returns whether the given arc is contained in the graph.

Must return the same value as Arcs().Contains in all implementations, but faster if possible.

Note
true may be returned for arcs coming from another graph as well, if those arcs encapsulate an identifier which is valid for this graph, too.

Implements Satsuma.IGraph.

Definition at line 295 of file Path.cs.

bool Satsuma.Path.HasNode ( Node  node)

Returns whether the given node is contained in the graph.

Must return the same value as Nodes().Contains in all implementations, but faster if possible.

Note
true may be returned for nodes coming from another graph as well, if those nodes encapsulate an identifier which is valid for this graph, too.

Implements Satsuma.IGraph.

Definition at line 290 of file Path.cs.

bool Satsuma.Path.IsEdge ( Arc  arc)

Returns whether the arc is undirected (true) or directed (false).

Implements Satsuma.IArcLookup.

Definition at line 234 of file Path.cs.

Arc Satsuma.Path.NextArc ( Node  node)

Returns the arc connecting a node with its successor in the path.

Returns Arc.Invalid if the node is not on the path or has no successor. If the path is a cycle, then each node has a successor.

Implements Satsuma.IPath.

Definition at line 212 of file Path.cs.

int Satsuma.Path.NodeCount ( )

Returns the total number of nodes in O(1) time.

Implements Satsuma.IGraph.

Definition at line 270 of file Path.cs.

IEnumerable<Node> Satsuma.Path.Nodes ( )

Returns all nodes of the graph.

Implements Satsuma.IGraph.

Definition at line 239 of file Path.cs.

Arc Satsuma.Path.PrevArc ( Node  node)

Returns the arc connecting a node with its predecessor in the path.

Returns Arc.Invalid if the node is not on the path or has no predecessor. If the path is a cycle, then each node has a predecessor.

Implements Satsuma.IPath.

Definition at line 218 of file Path.cs.

void Satsuma.Path.Reverse ( )

Reverses the path in O(1) time.

For example, the uvw path becomes the wvu path.

Definition at line 206 of file Path.cs.

Node Satsuma.Path.U ( Arc  arc)

Returns the first node of an arc. Directed arcs point from U to V.

Implements Satsuma.IArcLookup.

Definition at line 224 of file Path.cs.

Node Satsuma.Path.V ( Arc  arc)

Returns the second node of an arc. Directed arcs point from U to V.

Implements Satsuma.IArcLookup.

Definition at line 229 of file Path.cs.

Property Documentation

Node Satsuma.Path.FirstNode
getset

Definition at line 113 of file Path.cs.

IGraph Satsuma.Path.Graph
getset

The graph containing the path.

Definition at line 112 of file Path.cs.

Node Satsuma.Path.LastNode
getset

Definition at line 114 of file Path.cs.


The documentation for this class was generated from the following file: