QuickGraph.Algorithms
A static class with some helper methods
This class contains a number of small and usefull methods.
All the method are thread safe.
No constructor
Returns true if edge is a self edge
edge to test
true if self edge
e is null
Returns the vertex opposite to v on the edge e.
Given an edge and a vertex which must be incident to the edge,
this function returns the opposite vertex.
So if v is the source vertex, this function returns the target
vertex. I
f v is the target, then this function returns the source vertex.
e or v is null
v is not incident to e
Checks wheter an edge belongs to the edge set
graph containing the edge set
edge to test
true if e is in the graph edge set
Checks wheter a vertex belongs to the vertex set
graph containing the vertex set
vertex to test
true if v is in the graph vertex set
Checks wheter an edge that goes from source to target
belongs to the edge set
graph containing the edge set
edge source
edge target
true if e is in the graph edge set
Checks if the child vertex is a child of the parent vertex
using the predecessor map.
Checks if there exists a path between source and target
source vertex
target vertex
graph
true if target is reachable from source
Applies a topological sort to the graph
graph to sort
sorted vertices
Computes the connected components.
graph to explore
component map where results are recorded
number of components
Computes the strong components.
Thread safe.
graph to explore
component map where results are recorded
number of strong components
Returns an enumerable collection of the leaf vertices of the graph
graph to visit
enumerable of leaf vertices
Thread safe.
Returns an enumerable collection of the root vertices of the graph
graph to visit
enumerable of root vertices
Thread safe.
Computes the leaves from the vertex.
graph containing the vertex
root of the tree
leaf vertices
Checks that the graph does not have cyclies
graph to test
g is a null reference
graph contains a cycle
Used in OutEdgeTree
Checks that the sub graph rooted at does not have cyclies
graph to test
g is a null reference
graph contains a cycle
Create a collection of odd vertices
graph to visit
colleciton of odd vertices
g is a null reference
Floyd Warshall All Shortest Path Algorithm
Default constructor - initializes all fields to default values
Raises the event.
source vertex
target vertex
Raises the event.
source vertex
target vertex
Raises the event.
Raises the event.
Compute the All shortest path problem.
Checks the graph for connectivity and negative cycles
cost distionary
graph has negatice cycle.
graph is not strongly connected
Gets the visited graph
Visited Graph
Gets the instance
Internal use
Raised when initializing a new path
Raised when a path is reduced
Raised when a path is not reduced
Collection of classes that compute the All-Shortest path problem.
An all-shortest path algorithm computes all the shortest path between
all the graph vertices.
The runs in O(V^3).
It can also be used to compute other quantities: transitive hull,
safest path, min-max path, etc.
Those are trigerred by
classes.
Distance reducer interface
A implementation that augments a
such that
for all edge (u,v) there exists the edge (v,u) in the graph.
This algorithm can be used to augment a graph with reversed edges to make it usable by
a implementation. It also contains the method
to clean up the graph afterwards.
Augments the with reversed edges.
The graph has already been augmented.
Removes the reversed edges.
The graph is not yet augmented.
Gets a instance containing the
augmented edges.
Gets a associating
each edge to it's corresponding reversed edge.
Gets a value indicating wheter the
has been augmented.
Algorithm extracted from Efficient Algorithms for Constructing Testing Sets, Covering Paths and
Minimum Flows, Alfred V. Aho, David Lee.
Edge cloning event handler
Edge cloning event argument
Create a new Vertex cloning event argument
original vertex
clone vertex
or
is a null reference.
Original vertex
Clone vertex
Vertex cloning event handler
Vertex cloning event argument
Create a new Vertex cloning event argument
original vertex
clone vertex
or
is a null reference.
Gets the original vertex
Original vertex instance
Gets the clone vertex
Clone vertex instance
A graph cloner algorithm
Use this class to create clone of different graphs with possible different
provider types.
The and events can be
used to copy the custom properties
attached to each vertex and edge.
Makes a copy of the source graph to the clone graph.
source graph
clone graph
Clones the to and
reverses the edges.
Use this class to create clone of different graphs with possible different
provider types.
The and events can be
used to copy the custom properties
attached to each vertex and edge.
Triggers the CloneVertex event
Triggers the CloneEdge event
Event called on each vertex cloning
Event called on each edge cloning
The QuickGraph.Algorithms.Clone contains algorithms that
create copy of graph.
Creates a condensation graph transformation
Condensation Graph constructor
Input graph from
which condensation graph is created
Raise the CondensationGraphVertex evt
Pack the CG vertex and a VertexCollection of it's constituent vertices
Clear the extracted strongly connected components
Compute the condensation graph and store it in the supplied graph 'cg'
Instance of mutable graph in which the condensation graph
transformation is stored
Visited graph
Maps a graph vertex to a strongly connected component
Map of IVertex to strongly connected component ID
Read only map of vertices within each strongly connected component
map with StronglyConnectedComponent ID as key and IList of vertices as value
Raised when a new vertex is added in the condensation graph
Encapsulates a vertex in the original graph and it's corresponding
vertex in a transformation of the graph
ctor()
Vertex in the condensation graph
strongly connected
components
in the original graph which are represented by the condensation
graph node
Condensation graph vertex
Strongly connected vertices from original graph represented by the
condensation graph node
Delegate to handle the CondensationGraphVertexEvent
Connected component computation
The ConnectedComponentsAlgorithm functions compute the connected
components of an undirected graph using a DFS-based approach.
A connected component of an undirected graph is a set of vertices that
are all reachable from each other.
If the connected components need to be maintained while a graph is
growing the disjoint-set based approach of function
IncrementalComponentsAlgorithm is faster.
For ``static'' graphs this DFS-based approach is faster.
The output of the algorithm is recorded in the component
property Components, which will contain numbers giving the
component number assigned to each vertex.
Constructs a connected component algorithm.
graph to apply the algorithm on
g is null
Constructs a connected component algorithm, using a component map
graph
map where the components are recorded
g or components are null
Used internally
Used internally
Executes the algorithm
The total number of components is the return value of the function
Visited graph
Gets the component map
Component map
Gets the connected components count
Connected component count
The grid variant of the Fruchterman-Reingold graph layout algorithm.
This algorithm is based on the following paper:
T. Fruchterman and E. Reingold. "Graph drawing by force-directed placement." Software Practice and Experience, 21(11):1129--1164, 1991.
Implemented by Arun Bhalla.
Summary description for GridDirectedForcePotential.
Useful point algebra function.
Computes the Euclidian distance between two points
first point
second point
|p1-p2|_2
Computes the square of the Euclidian distance between two points
first point
second point
(p1.x-p2.x)^2+(p1.y-p2.y)^2
Edmonds-Karp Maximum Flow Algorithm
The class calculates
the maximum flow of a network. The calculated maximum flow will be
the return value of the function .
The function also calculates the flow values f[e] for all e in E,
which are returned in the form of the residual capacity
r[e] = c[e] - f[e].
There are several special requirements on the input graph
and property map parameters for this algorithm. First,
the directed graph G=(V,E) that represents the network must be augmented
to include the reverse edge for every edge in E. That is, the input graph
should be Gin = (V,{E U ET}).
The reversedEdges argument
must map each edge in the original graph to its reverse edge,
that is e=(u,v) -> (v,u) for all e in E.
The capacities argument must map each edge in E to a positive number,
and each edge in ET to 0.
The algorithm is due to Edmonds and Karp,
though we are using the variation called the labeling algorithm
described in Network Flows.
This algorithm provides a very simple and easy to implement solution
to the maximum flow problem. However, there are several reasons why
this algorithm is not as good as the
algorithm.
In the non-integer capacity case, the time complexity is O(V E^2)
which is worse than the time complexity of the
O(V^2E^1/2) for all but the sparsest of graphs.
In the integer capacity case, if the capacity bound U is very large then the
algorithm will take a long time.
Abstract base class for maximum flow algorithms.
Constructs a maximum flow algorithm.
Graph to compute maximum flow on.
edge capacities
reversed edge map
or
or is a null
reference.
Computes the maximum flow between and
The QuickGraph.Algorithms.MaximumFlow contains
algorithms to compute network maximum flows.
Under construction
Push-Relabel Maximum Flow Algorithm
The class calculates the
maximum flow of a network. The calculated maximum flow will be the return value of
the function. The function
also calculates the flow values f(u,v) for all (u,v) in E, which
are returned in the form of the residual capacity r(u,v) = c(u,v) - f(u,v).
There are several special requirements on the input graph and property map
parameters for this algorithm. First, the directed graph G=(V,E) that
represents the network must be augmented to include the reverse edge for every
edge in E. That is, the input graph should be Gin = (V,{E U E^T}).
The reversedEdges argument must map each edge in the original graph to
its reverse edge, that is (u,v) -> (v,u) for all (u,v) in E.
The capacities argument must map each edge in E to a
positive number, and each edge in E^T to 0.
This algorithm was developed by Goldberg.
Computes the maximum flow between and
.
The source node of the graph.
The sink node of the graph.
The maximum flow of the graph.
This is the core part of the algorithm, "phase one."
Summary description for VertexCoverageMetric.
The QuickGraph.Algorithms.Metrics contains metrics to
caracterize traversals, trees and graphs.
Summary description for VertexCoverageMetric.
Algorithm extracted from Efficient Algorithms for Constructing Testing Sets, Covering Paths and
Minimum Flows, Alfred V. Aho, David Lee.
The QuickGraph.Algorithms namespace is the base namespace
for graph algorithms.
This namespace contains all the graph algorithms implements by quickgraph.
Algorithms are classified by the type of problem they solve, and each
problem is separated in it's own namespace:
-
Search
Basic algorithms such as the or
the .
-
ShortestPath
Computes the single source shortest path problem.
-
Clone
Cloning of graph related algorithms
-
MaximumFLow
Netword maximu flow algorithms
A number of algorithm supports visitors defined in the Visitor namespace.
The QuickGraph.Algorithms.PerfectMatching namespace
contains classes for solving Minimum Weight Perfect Matching
problems.
A perfect matching of a graph G is a subset of edges
such that each node in G is met by exactly one edge of the matching.
Given a real weight ec for each edge e in G, a
Minimum Weight Perfect Matching problem is to find
a perfect matching M of minimum weight.
Wilson-Propp Cycle-Popping Algorithm for Random Tree Generation.
This class implements cycle-popping algorithms extracted from Section 6 and 7 of
How to Get Perfectly
Random Sample from a Generic Markov Chain and Generate a Random
Spanning Tree of a Directed Graph., by James Gary Propp and
David Bruce Wilson. If you want a deepter understanding of the article,
it is suggested to you have a look at this excellent paper.
The class implements two algorithms, namely RandomTreeWithRoot
and RandomTree.
These algorithms apply to general digraphs. No strong connectivity is needed.
It must be emphasized that this algorithms generates trees where the edges are directe
towards the root.
Constructs the algorithm around .
visted graph
g is a null reference
Constructs the algorithm around using
the Markov chain.
visited graph
Markov chain generator
or
is a null reference
Raises the event.
vertex being initialized
Raises the event.
vertex being terminated
Raises the event.
edge being added to the tree
Raises the event.
vertex being removed
Initializes the tree.
Initializes the color dictionary and raises
the event for each
in the graph.
Gets a value indicating if is
not in the tree.
This method checks that color is white.
vertex to test
true if not in the tree, false otherwise.
Adds to the tree and raises the
event.
Set color to black.
vertex to add
Gets the next out-edge according to
the Markov Chain generator.
This method uses the instance
to compute the next random out-edge. If has
no out-edge, null is returned.
Source vertex
next edge in the chain, null if u has no out-edges
Sets as the next edge of
in the tree, and raises the event.
If is null, nothing is done.
source vertex
next edge in tree
Gets the next vertex in the tree.
source vertex
next vertex in tree if any, null otherwise
Clears from the tree and raises the
event.
vertex to clear
Generates a random tree rooted at .
This method implements the Cycle-Hopping Random Tree generation
algorithm proposed in Propp-Wilson paper. See class summary for
further details.
root vertex
root is a null reference
Generates a random tree with no specified root.
Attemps to create a new random tree with probability transition
.
probability transition
true if random tree generated, false otherwise
Gets the visited instance
Visited instance
Get the color dictionary
Vertex color dictionary
Gets or sets the Markov chain.
Markov chain.
set property, value is a null reference.
Gets or sets the random number generator used in RandomTree.
number generator
Gets the dictionary of vertex edges successors in the generated
random tree.
Vertex - Edge successor dictionary.
Occurs when a vertex is initialized
Occurs when a vertex is added to the tree.
Occurs when an edge is added to the tree.
Occurs when a vertex is removed from the tree.
When implemented by a class, defines methods to generate a
random Markov chain of .
This interface defines the Successor method which generates
a Markov chain of . Implemented classes can choose
the according distribution properties.
Selects the next out- in the Markov Chain.
visted graph
source vertex
Random next out-edge
or is a null reference
Summary description for Markov.
The QuickGraph.Algorithms.RandomWalks contains
algorithm to generate random walks or trees over graphs.
Markov chain generator with the propability vector
equally distributed over the out-edges.
This class can be used to generate a Markov Chain of
instance. The probability vector is computed such that each
out-edge has the same probability:
outEdgeCount = OutDegree(u)
Pr[e_i] = 1/outEdgeCount
Selects the next out- in the Markov Chain.
visted graph
source vertex
Random next out-edge
or is a null reference
Gets or sets the random generator
Random number generator
Stochastic Random Walk Generation.
This algorithms walks randomly across a directed graph. The probability
to choose the next out-edges is provided by a
instance.
Events
The is raised on the root vertex of the walk.
This event is raised once.
On each new edge in the walk, the is raised with
the edge added to the walk tree.
The is raised on the last vertex of the walk.
This event is raised once.
Custom end of walk condition can be provided by attacing a
instance to the
property.
ea
In this example, we walk in a graph and output the edge using
events:
// define delegates
public void TreeEdge(Object sender, EdgeEventArgs e)
{
Console.WriteLine(
"{0}->{1}",
e.Edge.Source.ToString(),
e.Edge.Target.ToString());
}
...
IVertexListGraph g = ...;
// create algo
RandomWalkAlgorithm walker = new RandomWalkAlgorithm(g);
// attach event handler
walker.TreeEdge += new EdgeEventHandler(this.TreeEdge);
// walk until we read a dead end.
waler.Generate(int.MaxValue);
Constructs the algorithm around .
visted graph
g is a null reference
Constructs the algorithm around using
the Markov chain.
visited graph
Markov chain generator
or
is a null reference
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
edge being added to the tree
Gets the next out-edge according to
the Markov Chain generator.
This method uses the instance
to compute the next random out-edge. If has
no out-edge, null is returned.
Source vertex
next edge in the chain, null if u has no out-edges
Generates a walk of steps
number of steps
Generates a walk of steps
root vertex
number of steps
Gets the visited instance
Visited instance
Gets or sets the Markov chain.
Markov chain.
set property, value is a null reference.
Gets or sets the random number generator used in RandomTree.
number generator
Gets or sets an end of traversal predicate.
End of traversal predicate.
Raised on the source vertex once before the start of the search.
Raised on the sink vertex once after the end of the search.
Occurs when an edge is added to the tree.
Summary description for VanishingWeightedMarkovEdgeChain.
Markov chain generator with the propability vector
distributed over the out-edges weights.
This class can be used to generate a Markov Chain of
instance. The probability vector is computed such that each
out-edge weight sum is 1 (to have a stochastic vector):
outWeight = \sum weight[e_i]
Pr[e_i] = weight[e_i]/outWeight
Construct a markov chain based on the
edge weight dictionary.
edge weight dictionary
weights is a null reference
Selects the next out- in the Markov Chain.
visted graph
source vertex
Random next out-edge
or is a null reference
Gets or sets the random generator
Random number generator
Gets the edge-weight dictionary
Edge weight dictionary
Algorithm that computes the PageRank ranking over a graph.
PageRank is a method that initially designed to rank web pages
objectively and mechanically. In fact, it is one of the building block
of the famous Google search engine.
The idea behind PageRank is simple and intuitive: pages that are important are referenced
by other important pages. There is an important literature on the web that explains
PageRank: http://www-db.stanford.edu/~backrub/google.html,
http://www.webworkshop.net/pagerank.html,
http://www.miswebdesign.com/resources/articles/pagerank-2.html
The PageRank is computed by using the following iterative formula:
PR(A) = (1-d) + d (PR(T1)/C(T1) + ... + PR(Tn)/C(Tn))
where PR is the PageRank, d is a damping factor usually set to 0.85,
C(v) is the number of out edgesof v.
Creates a PageRank algorithm around the visited graph
Visited instance.
is a null reference (Nothing in Visual Basic).
Initializes the rank map.
This method clears the rank map and populates it with rank to one for all vertices.
Iteratively removes the dangling links from the rank map
Computes the PageRank over the .
Gets the visited graph
A instance
Gets the page rank dictionary
The of - rank entries.ank entries.
Gets or sets the damping factor in the PageRank iteration.
Damping factor in the PageRank formula (d).
Gets or sets the tolerance to stop iteration
The tolerance to stop iteration.
Gets or sets the maximum number of iterations
The maximum number of iteration.
A mutable incidence graph implemetation
Builds a new empty directed graph with default vertex and edge
provider.
Builds a new empty directed graph with default vertex and edge
provider.
true if parallel edges are allowed
Builds a new empty directed graph with custom providers
true if the graph allows
multiple edges
custom edge provider
custom vertex provider
vertexProvider or edgeProvider is a null reference
Remove all of the edges and vertices from the graph.
Add a new vertex to the graph and returns it.
Complexity: 1 insertion.
Create vertex
Add a new vertex to the graph and returns it.
Complexity: 1 insertion.
Create vertex
Add a new vertex from source to target
Complexity: 2 search + 1 insertion
Source vertex
Target vertex
Created Edge
source or target is null
source or target are not part of the graph
Used for serialization. Not for private use.
edge to add.
Gets a value indicating if the set of out-edges is empty
Usually faster that calling .
true if the out-edge set is empty, false otherwise.
v is a null reference
Returns the number of out-degree edges of v
vertex
number of out-edges of the v
Returns an iterable collection over the edge connected to v
Incidence graph implementation
Returns the first out-edge that matches the predicate
Edge predicate
null if not found, otherwize the first Edge that
matches the predicate.
v or ep is null
Returns the collection of out-edges that matches the predicate
Edge predicate
enumerable colleciton of vertices that matches the
criteron
v or ep is null
Removes the vertex from the graph.
vertex to remove
v is null
Remove all edges to and from vertex u from the graph.
Removes an edge from the graph.
Complexity: 2 edges removed from the vertex edge list + 1 edge
removed from the edge list.
edge to remove
e is null
Remove the edge (u,v) from the graph.
If the graph allows parallel edges this remove all occurrences of
(u,v).
source vertex
target vertex
Remove all the edges from graph g for which the predicate pred
returns true.
edge predicate
Remove all the out-edges of vertex u for which the predicate pred
returns true.
vertex
edge predicate
Returns the first vertex that matches the predicate
vertex predicate
null if not found, otherwize the first vertex that
matches the predicate.
vp is null
Returns the collection of vertices that matches the predicate
vertex predicate
enumerable colleciton of vertices that matches the
criteron
vp is null
Tests if a vertex is part of the graph
Vertex to test
true if is part of the graph, false otherwize
Returns the first Edge that matches the predicate
Edge predicate
null if not found, otherwize the first Edge that
matches the predicate.
ep is null
Returns the collection of edges that matches the predicate
Edge predicate
enumerable colleciton of vertices that matches the
criteron
ep is null
Tests if a edge is part of the graph
Edge to test
true if is part of the graph, false otherwize
Test if an edge (u,v) is part of the graph
source vertex
target vertex
true if part of the graph
Gets an enumerable collection of adjacent vertices
Enumerable collection of adjacent vertices
Gets a value indicating if the graph is directed.
true if the graph is directed, false if undirected.
Gets a value indicating if the graph allows parralell edges.
true if the graph is a multi-graph, false otherwise
Vertex Out edges dictionary
Dictionary of to out edge collection.
Gets the provider
provider
Gets the provider
provider
Gets a value indicating if the vertex set is empty
Usually faster (O(1)) that calling VertexCount.
true if the vertex set is empty, false otherwise.
Gets the number of vertices
Number of vertices in the graph
Enumerable collection of vertices.
Gets a value indicating if the vertex set is empty
Usually faster that calling .
true if the vertex set is empty, false otherwise.
Gets the edge count
Edges count
Enumerable collection of edges.
IEdgeListGraph implementation
Creates a bidirectional graph out of a
graph.
This class adapts a to support
in-edge traversal. Be aware, that the in-edge traversal is less
efficient that using specialized classes.
Constructor
Gets a value indicating if the set of out-edges is empty
Usually faster that calling .
true if the out-edge set is empty, false otherwise.
v is a null reference
Returns the number of out-degree edges of v
vertex to test
out-degree
Returns an iterable collection of the out edges of v
Gets a value indicating if the set of in-edges is empty
Usually faster that calling .
true if the in-edge set is empty, false otherwise.
v is a null reference
Returns the number of in-edges (for directed graphs) or the number
of incident edges (for undirected graphs) of vertex v in graph g.
vertex to test
out-degree
Gets a value indicating if the set of edges connected to v is empty
Usually faster that calling .
true if the adjacent edge set is empty, false otherwise.
v is a null reference
Returns the number of in-edges plus out-edges (for directed graphs)
or the number of incident edges (for undirected graphs) of
vertex v in graph g.
vertex to test
out-degree
Enumerable collection of in-edges
Returns an enumerable collection of in-edges (for directed graphs)
or incident edges (for undirected graphs) of vertex v in graph g.
For both directed and undirected graphs, the target of an out-edge
is required to be vertex v and the source is required to be a
vertex that is adjacent to v.
Gets an enumerable collection of the v adjacent vertices
Adapted graph
Directed state
True if parallel edges allowed
A mutable bidirectional graph implemetation
Builds a new empty graph with default vertex and edge providers
Builds a new empty graph
Remove all of the edges and vertices from the graph.
Add a new vertex to the graph and returns it.
Complexity: 1 insertion.
Create vertex
Adds a new vertex to the graph.
Add a new vertex from source to target
Complexity: 2 search + 1 insertion
Source vertex
Target vertex
Created Edge
source or target is null
source or target are not part of the graph
Adds a new edge to the graph
Gets a value indicating if the set of in-edges is empty
Usually faster that calling .
true if the in-edge set is empty, false otherwise.
v is a null reference
Returns the number of in-degree edges of v
Returns an iterable collection over the in-edge connected to v
Incidence graph implementation
Returns the first in-edge that matches the predicate
Edge predicate
null if not found, otherwize the first Edge that
matches the predicate.
v or ep is null
Returns the collection of in-edges that matches the predicate
Edge predicate
enumerable colleciton of vertices that matches the
criteron
v or ep is null
Removes the vertex from the graph.
vertex to remove
v is null
Remove all edges to and from vertex u from the graph.
Removes an edge from the graph.
Complexity: 2 edges removed from the vertex edge list + 1 edge
removed from the edge list.
edge to remove
e is null
Remove the edge (u,v) from the graph.
If the graph allows parallel edges this remove all occurrences of
(u,v).
source vertex
target vertex
Remove all the out-edges of vertex u for which the predicate pred
returns true.
vertex
edge predicate
Gets a value indicating if the set of edges connected to v is empty
Usually faster that calling .
true if the adjacent edge set is empty, false otherwise.
v is a null reference
Returns the number of in-edges plus out-edges.
Vertex Out edges dictionary
A clustered adjacency graph
This class implements a clustered :
an
that has sub-graphs (clusters). Each cluster is a
which can also have sub-graphs.
Suppose that G=(V,E) is the main graph and
that G1=(V1,E1) is a cluster:
-
If v is added to V1, then v also
belongs to V.
-
If v is added to V, then v does not
belong to V1.
Threading:
Not thread safe.
Constructs a on top of
the object.
parent graph
Construct a cluster inside another cluster
Determines whether the
contains the edge .
The edge to locate in .
true if the contains
the edge ; otherwise, false.
Determines whether the
contains an edge from the vertex to
the vertex .
The source vertex of the edge(s) to locate in .
The target vertex of the edge(s) to locate in .
true if the contains
the edge (, ); otherwise, false.
Determines whether the
contains the vertex .
The vertex to locate in .
true if the contains
the vertex ; otherwise, false.
Gets a filtered collection of edges.
edge predicate
filetered collection
Gets a value indicating if the set of out-edges is empty
Usually faster that calling .
true if the out-edge set is empty, false otherwise.
v is a null reference
Adds a new cluster.
New cluster
Removes a cluster
cluster to remove
cluster is a null reference.
Adds a new vertex to the cluster
new vertex
Adds an existing vertex to the cluster
vertex to add
Adds a new edge
source vertex
target edge
added edge
u or v is a null reference
Adds an existing edge to the cluster
edge to add
Removes a vertex from the cluster
Clears vertex out-edges
Remove a specific edge
Remove edges from u to v
Remove out edge satisfying the predicate
Remove edge satifying the predicate
Gets an enumerable collection of the v adjacent vertices
Gets the parent .
Parent .
Not implemented yet.
Gets the wrapped object.
Wrapped object. Can be a
.
Gets a value indicating whether the graph is directed.
true if the graph is directed, false otherwize.
Gets a value indicating whether the graph allows parallel edges.
true if the graph allows parallel edges, false otherwize.
Gets the used to generate the vertices.
instance used to generate the new
vertices.
Gets the used to generate the edges.
instance used to generate the new
edges.
Gets a value indicating if the vertex set is empty
Usually faster that calling .
true if the vertex set is empty, false otherwise.
Gets an enumerable collection of edges.
collection of edges.
Gets the edge count.
Edge count.
Complexity: O(E)
Gets a value indicating if the vertex set is empty
Usually faster (O(1)) that calling VertexCount.
true if the vertex set is empty, false otherwise.
Gets an enumerable collection of vertices.
collection of vertices.
Gets the vertex count.
Vertex count.
Complexity: O(V)
Gets an enumerable collection of clusters
Enumerable collection of clusters
Gets the number of clusters
Number of clusters
An edge-list representation of a graph is simply a sequence of edges,
where each edge is represented as a pair of vertex ID's.
The EdgeList class is an adaptor that turns an edge collection
into a class that models IEdgeListGraph.
The value type of the edge collection must be be inherited form IEdge.
An edge-list representation of a graph is simply a sequence of edges,
where each edge is represented as a pair of vertex ID's.
The memory required is only O(E). Edge insertion is typically O(1),
though accessing a particular edge is O(E) (not efficient).
Builds an EdgeListGraph out of a edges collection
Gets a value indicating if the vertex set is empty
Usually faster that calling .
true if the vertex set is empty, false otherwise.
Returns the number of edges in the graph.
Returns an enumerator providing access to all the edges in the graph.
IEdgeListGraph implemetentation.
A mutable tree-like graph
A tree-like wrapper for bidirectional graph
This interface defines a DOM like tree node structure.
Graphs used with this interface must be directed, not
allowing parrallel edges. However, they can be cylic
but the in-degree of each vertex must be equal to 1.
Wraps a graph into a tree-like structure
Gets the parent.
current vertex
parent vertex if any, null reference otherwize
is a null reference
has multiple in-edges
Gets the first adjacent vertex
current vertex
first out-vertex
is a null reference
is a null reference
Gets a value indicating if the has out-edges
to test
true if has out-edges.
is a null reference
Gets an enumerable collection of child
current
An enumerable collection of adjacent vertices
is a null reference
Gets the wrapped instance.
Creates a mutable tree wrapper
wrapped graph
cycle tolerance
Adds a child vertex to the tree
parent vertex
created vertex
parent is a null reference
if AllowCycles is false and the edge creates a cycle
Removes vertex and sub-tree
vertex to remove
v is a null reference
Removing the vertex breaks the graph connectivity
Gets a value indicating if the tree allows cycles
true if it allows cycle, false otherwise
The QuickGraph.Representations namespace contains
implementations of the graph concepts (traversal concepts and
modification concepts).
A mutable incidence graph implemetation
Builds a new empty directed graph with default vertex and edge
provider.
Builds a new empty directed graph with default vertex and edge
provider.
true if parallel edges are allowed
Builds a new empty directed graph with custom providers
true if the graph allows
multiple edges
custom edge provider
custom vertex provider
vertexProvider or edgeProvider is a null reference
Remove all of the edges and vertices from the graph.
Add a new vertex to the graph and returns it.
Complexity: 1 insertion.
Create vertex
Add a new vertex to the graph and returns it.
Complexity: 1 insertion.
Create vertex
Add a new vertex from source to target
Complexity: 2 search + 1 insertion
Source vertex
Target vertex
Created Edge
source or target is null
source or target are not part of the graph
Used for serialization. Not for private use.
edge to add.
Gets a value indicating if the set of out-edges is empty
Usually faster that calling .
true if the out-edge set is empty, false otherwise.
v is a null reference
Returns the number of out-degree edges of v
vertex
number of out-edges of the v
Returns an iterable collection over the edge connected to v
Incidence graph implementation
Returns the first out-edge that matches the predicate
Edge predicate
null if not found, otherwize the first Edge that
matches the predicate.
v or ep is null
Returns the collection of out-edges that matches the predicate
Edge predicate
enumerable colleciton of vertices that matches the
criteron
v or ep is null
Removes the vertex from the graph.
vertex to remove
v is null
Remove all edges to and from vertex u from the graph.
Removes an edge from the graph.
Complexity: 2 edges removed from the vertex edge list + 1 edge
removed from the edge list.
edge to remove
e is null
Remove the edge (u,v) from the graph.
If the graph allows parallel edges this remove all occurrences of
(u,v).
source vertex
target vertex
Remove all the edges from graph g for which the predicate pred
returns true.
edge predicate
Remove all the out-edges of vertex u for which the predicate pred
returns true.
vertex
edge predicate
Returns the first vertex that matches the predicate
vertex predicate
null if not found, otherwize the first vertex that
matches the predicate.
vp is null
Returns the collection of vertices that matches the predicate
vertex predicate
enumerable colleciton of vertices that matches the
criteron
vp is null
Tests if a vertex is part of the graph
Vertex to test
true if is part of the graph, false otherwize
Returns the first Edge that matches the predicate
Edge predicate
null if not found, otherwize the first Edge that
matches the predicate.
ep is null
Returns the collection of edges that matches the predicate
Edge predicate
enumerable colleciton of vertices that matches the
criteron
ep is null
Tests if a edge is part of the graph
Edge to test
true if is part of the graph, false otherwize
Test is an edge (u,v) is part of the graph
source vertex
target vertex
true if part of the graph
Gets an enumerable collection of adjacent vertices
Enumerable collection of adjacent vertices
Gets a value indicating if the graph is directed.
true if the graph is directed, false if undirected.
Gets a value indicating if the graph allows parralell edges.
true if the graph is a multi-graph, false otherwise
Vertex Out edges dictionary
Dictionary of to out edge collection.
Gets the provider
provider
Gets the provider
provider
Gets a value indicating if the vertex set is empty
Usually faster (O(1)) that calling VertexCount.
true if the vertex set is empty, false otherwise.
Gets the number of vertices
Number of vertices in the graph
Enumerable collection of vertices.
Gets a value indicating if the vertex set is empty
Usually faster that calling .
true if the vertex set is empty, false otherwise.
Gets the edge count
Edges count
Enumerable collection of edges.
IEdgeListGraph implementation
Summary description for Representation.
Records all the vertices that are part of the out-subtree of v
visited graph
root vertex
Maximum exploration depth
Records all the vertices that are part of the in-subtree of v
visited graph
root vertex
Maximum exploration depth
Records all the edges that are part of the subtree of v
visited graph
root edge
maximum expolration depth
Records all the edges that are part of the subtree of v
visited graph
root edge
maximum expolration depth
Used in OutEdgeTree
Adaptor to flip in-edges and out-edges.
This adaptor flips the in-edges and out-edges of a IBidirectionalGraph,
effectively transposing the graph.
The construction of the reverse graph is constant time,
providing a highly efficient way to obtain a transposed-view of a
graph.
Construct a reversed graph adaptor
Graph to adapt
Gets a value indicating if the set of in-edges is empty
Usually faster that calling .
true if the in-edge set is empty, false otherwise.
v is a null reference
Flipped out-degree
vertex to compute
transposed out-edgree
Gets a value indicating if the set of out-edges is empty
Usually faster that calling .
true if the out-edge set is empty, false otherwise.
v is a null reference
Flipped in-degree
vertex to compute
transposed in-edgree
Gets a value indicating if the set of edges connected to v is empty
Usually faster that calling .
true if the adjacent edge set is empty, false otherwise.
v is a null reference
Vertex degree
vertex to compute
vertex edgree
Returns a transposed out-edges enumerable
vertex to compute
transposed out edges enumerable
Returns a transposed in-edges enumerable
vertex to compute
transposed in edges enumerable
Check the graph contains an edge from
to .
Gets an enumerable collection of the v adjacent vertices
Reversed graph
Performs a breadth-first traversal
of a directed or undirected graph.
A breadth-first-search (BFS) traversal visits vertices that are closer to the
source before visiting vertices that are further away.
In this context ``distance'' is defined as the number of edges in the
shortest path from the source vertex.
The BFS can be used to compute the shortest
path from the source to all reachable vertices and the resulting
shortest-path distances.
BFS uses two data structures to to implement the traversal:
a color marker for each vertex and a queue.
White vertices are undiscovered while gray vertices are discovered
but have undiscovered adjacent vertices. Black vertices are discovered
and are adjacent to only other black or gray vertices.
The algorithm proceeds by removing a vertex u from the queue and
examining each out-edge (u,v). If an adjacent vertex v is not already
discovered, it is colored gray and placed in the queue. After all of
the out-edges are examined, vertex u is colored black and the process
is repeated. Pseudo-code for the BFS algorithm is a listed below.
IVertexListGraph g;
BFS(IVertex s)
{
// initialize vertices
foreach(IVertex u in g.Vertices)
{
Colors[u] = White;
OnInitializeVertex(u); // event
}
Visit(s);
}
Visit(IVertex s)
{
Colors[s]=GraphColor.Gray;
OnDiscoverVertex(s); //event
m_Q.Push(s);
while (m_Q.Count != 0)
{
IVertex u = m_Q.Peek();
m_Q.Pop();
OnExamineVertex(u); // event
foreach(Edge e in g.OutEdges(u))
{
OnExamineEdge(e); // event
GraphColor vColor = Colors[e.Target];
if (vColor == GraphColor.White)
{
OnTreeEdge(e); // event
OnDiscoverVertex(v); // event
Colors[v]=GraphColor.Gray;
m_Q.Push(v);
}
else
{
OnNonTreeEdge(e);
if (vColor == GraphColor.Gray)
{
OnGrayTarget(e); // event
}
else
{
OnBlackTarget(e); //event
}
}
}
Colors[u]=GraphColor.Black;
OnFinishVertex(this, uArgs);
}
}
This algorithm is directly inspired from the
BoostGraphLibrary implementation.
BreadthFirstSearch searcher constructor
Graph to visit
BreadthFirstSearch searcher contructor
Graph to visit
Vertex buffer
Vertex color map
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
vertex that raised the event
Computes the bfs starting at s
starting vertex
s is null
This method initializes the color map before appliying the visit.
Computes the bfs starting at s without initalization.
starting vertex
current depth
s is null
Registers the predecessors handler
Visited graph
Gets the to dictionary
to dictionary
Invoked on every vertex before the start of the search
Invoked in each vertex as it is removed from the queue
Invoked the first time the algorithm encounters vertex u.
All vertices closer to the source vertex have been discovered,
and vertices further from the source have not yet been discovered.
Invoked on every out-edge of each vertex immediately after the vertex is removed from the queue.
Invoked (in addition to ExamineEdge()) if the edge is a tree edge.
The target vertex of edge e is discovered at this time.
Invoked (in addition to examine_edge()) if the edge is not a tree
edge.
Invoked (in addition to non_tree_edge()) if the target vertex is
colored gray at the time of examination. The color gray indicates
that the vertex is currently in the queue.
Invoked (in addition to NonTreeEdge()) if the target vertex is
colored black at the time of examination. The color black indicates
that the vertex is no longer in the queue.
Invoked after all of the out edges of u have been examined
and all of the adjacent vertices have been discovered.
The DepthFirstSearchAlgorithm performs a depth-first traversal of the
vertices in a directed graph.
When possible, a depth-first traversal chooses a vertex adjacent to
the current vertex to visit next. If all adjacent vertices have
already been discovered, or there are no adjacent vertices,
then the algorithm backtracks to the last vertex that had undiscovered
neighbors. Once all reachable vertices have been visited, the algorithm
selects from any remaining undiscovered vertices and continues the
traversal. The algorithm finishes when all vertices have been visited.
Depth-first search is useful for categorizing edges in a graph,
and for imposing an ordering on the vertices.
Similar to the , color
markers are used to keep track of which vertices have been discovered.
White marks vertices that have yet to be discovered,
gray marks a vertex that is discovered but still has vertices adjacent
to it that are undiscovered. A black vertex is discovered vertex that
is not adjacent to any white vertices.
The main loop pseudo-code is as follows:
IVertexListGraph g;
DFS(IVertex s)
{
// initialize vertex colors
foreach(IVertex v in g.Vertices)
{
Colors[v] = White;
InitializeVertex(v); // event
}
// if there is a starting vertex, visit it
if (s != null)
{
StartVertex(s); // event
Visit(s);
}
// visit all vertices, if not previously visited
foreach(IVertex v in g.Vertices)
{
if (Colors[v] != White)
{
StartVertex(v); // event
Visit(v);
}
}
}
The Visit method pseudo-code is as follows:
Visit(IVertexListGraph g, IVertex u)
{
Colors[u] = Gray;
OnDiscoverVertex(u); // event
// examine edges
foreach(IEdge e in g.OutEdges(u))
{
OnExamineEdge(e); // event
if (Colors[u] == White)
{
OnTreeEdge(e); // event
Visit(e.Target);
}
else if (Colors[u] == Gray)
{
OnBackEdge(e); // event
}
else
OnForwardOrCrossEdge(e); // event
}
Colors[u] = Black;
OnFinishVertex(u); // event
}
In itself the algorithm does not take action, it is the user
job to attach handlers to the different events that take part during
the algorithm:
Event
When
-
InitializeVertex
Invoked on every vertex of the graph before the start of the graph
search.
-
StartVertex
Invoked on the source vertex once before the start of the search.
-
DiscoverVertex
Invoked when a vertex is encountered for the first time.
-
ExamineEdge
Invoked on every out-edge of each vertex after it is discovered.
-
TreeEdge
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
-
BackEdge
Invoked on the back edges in the graph.
-
FowardOrCrossEdge
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
-
FinishVertex
Invoked on a vertex after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
Predifined visitors, such as
and
can be used with this algorithm.
This algorithm is directly inspired from the
BoostGraphLibrary implementation.
A depth first search algorithm on a directed graph
The graph to traverse
g is null
A depth first search algorithm on a directed graph
The graph to traverse
vertex color map
g or colors are null
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
vertex that raised the event
Execute the DFS search.
Execute the DFS starting with the vertex s
Starting vertex
Initializes the vertex color map
Does a depth first search on the vertex u
vertex to explore
current recursion depth
u cannot be null
Registers the predecessors handler
Visited graph
Gets the vertex color map
Vertex color () dictionary
IVertexColorizerAlgorithm implementation
Gets or sets the maximum exploration depth, from
the start vertex.
Defaulted at int.MaxValue.
Maximum exploration depth.
Invoked on every vertex of the graph before the start of the graph
search.
Invoked on the source vertex once before the start of the search.
Invoked when a vertex is encountered for the first time.
Invoked on every out-edge of each vertex after it is discovered.
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on a vertex after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
The EdgeDepthFirstSearchAlgorithm performs a depth-first traversal of the
edges in a directed graph.
A depth first search algorithm on a directed graph
The graph to traverse
g is null
A depth first search algorithm on a directed graph
The graph to traverse
vertex color map
g or colors are null
Triggers the ForwardOrCrossEdge event.
Triggers the StartVertex event.
Triggers the StartEdge event.
Triggers DiscoverEdge event
Triggers the TreeEdge event.
Triggers the BackEdge event.
Triggers the ForwardOrCrossEdge event.
Triggers the ForwardOrCrossEdge event.
Compute the algorithm starting at the first vertex.
Execute the EDFS starting with the vertex s
Starting vertex
Initiliaze color map
Does a depth first search on the vertex u
edge to explore
current exploration depth
se cannot be null
Registers the handlers of a
visitor.
visitor to "attach"
Registers the handlers of a
visitor.
visitor to "attach"
Gets the visited graph
The visited graph
Gets the edge dictionary
Edge dictionary
Gets or sets the maximum exploration depth, from
the start edge.
Defaulted at int.MaxValue.
Maximum exploration depth.
Invoked on every vertex of the graph before the start of the graph
search.
Invoked on the source vertex once before the start of the search.
Invoked on the first edge of a test case
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on a edge after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
The EdgeDepthFirstSearchAlgorithm performs a depth-first traversal of the
edges in a directed graph.
A depth first search algorithm on a directed graph
The graph to traverse
g is null
A depth first search algorithm on a directed graph
The graph to traverse
vertex color map
g or colors are null
Triggers the ForwardOrCrossEdge event.
Triggers the StartVertex event.
Triggers the StartEdge event.
Triggers DiscoverEdge event
Triggers the TreeEdge event.
Triggers the BackEdge event.
Triggers the ForwardOrCrossEdge event.
Triggers the ForwardOrCrossEdge event.
Compute the algorithm starting at the first vertex.
Execute the EDFS starting with the vertex s
Starting vertex
Initiliaze color map
Does a depth first search on the vertex u
edge to explore
current exploration depth
se cannot be null
Registers the handlers of a
visitor.
visitor to "attach"
Registers the handlers of a
visitor.
visitor to "attach"
Gets the visited graph
The visited graph
Gets the edge dictionary
Edge dictionary
Gets or sets the maximum exploration depth, from
the start edge.
Defaulted at int.MaxValue.
Maximum exploration depth.
Invoked on every vertex of the graph before the start of the graph
search.
Invoked on the source vertex once before the start of the search.
Invoked on the first edge of a test case
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on a edge after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
A height first search algorithm on a directed graph
The graph to traverse
g is null
A height first search algorithm on a directed graph
The graph to traverse
vertex color map
g or colors are null
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
vertex that raised the event
Execute the DFS search.
Execute the DFS starting with the vertex s
Starting vertex
Initializes the vertex color map
Does a depth first search on the vertex u
vertex to explore
current recursion depth
u cannot be null
Registers the predecessors handler
Visited graph
Gets the vertex color map
Vertex color () dictionary
IVertexColorizerAlgorithm implementation
Gets or sets the maximum exploration depth, from
the start vertex.
Defaulted at int.MaxValue.
Maximum exploration depth.
Invoked on every vertex of the graph before the start of the graph
search.
Invoked on the source vertex once before the start of the search.
Invoked when a vertex is encountered for the first time.
Invoked on every out-edge of each vertex after it is discovered.
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on a vertex after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
vertex that raised the event
Does an implicit depth first search on the graph
Start vertex of the depth first search
Initializes the algorithm before computation.
Visit vertex .
Registers the predecessors handler
Gets the Visited graph
Gets the vertex color map
Vertex color () dictionary
Gets or sets the maximum exploration depth, from
the start vertex.
Defaulted at int.MaxValue.
Maximum exploration depth.
Invoked on the source vertex once before the start of the search.
Invoked when a vertex is encountered for the first time.
Invoked on every out-edge of each vertex after it is discovered.
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on a vertex after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
Triggers the StartVertex event.
Triggers the StartEdge event.
Triggers DiscoverEdge event
Triggers the TreeEdge event.
Triggers the BackEdge event.
Triggers the ForwardOrCrossEdge event.
Triggers the ForwardOrCrossEdge event.
Does an implicit depth first search on the graph
Start vertex of the depth first search
Does a depth first search on the vertex u
edge to explore
current exploration depth
se cannot be null
Initializes the algorithm before computation.
Registers the handlers of a
visitor.
visitor to "attach"
Gets the Visited graph
Gets the vertex color map
Vertex color () dictionary
Gets or sets the maximum exploration depth, from
the start vertex.
Defaulted at int.MaxValue.
Maximum exploration depth.
Invoked on the source vertex once before the start of the search.
Invoked on the first edge of a test case
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on a edge after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
The QuickGraph.Algorithms.Search namespace contains basic
algorithms, such as the
that are the building blocks other more complex algorithms.
Summary description for NeighborBreadthFirstSearch.
The DepthFirstSearchAlgorithm performs a depth-first traversal of the
vertices in a directed graph.
A depth first search algorithm on a directed graph
The graph to traverse
g is null
A depth first search algorithm on a directed graph
The graph to traverse
vertex color map
g or colors are null
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
vertex that raised the event
Execute the DFS search.
Execute the DFS starting with the vertex s
Starting vertex
Initializes the vertex color map
Does a depth first search on the vertex u
vertex to explore
current recursion depth
u cannot be null
Registers the predecessors handler
Visited graph
Gets the vertex color map
Vertex color () dictionary
IVertexColorizerAlgorithm implementation
Gets or sets the maximum exploration depth, from
the start vertex.
Defaulted at int.MaxValue.
Maximum exploration depth.
Invoked on every vertex of the graph before the start of the graph
search.
Invoked on the source vertex once before the start of the search.
Invoked when a vertex is encountered for the first time.
Invoked on every out-edge of each vertex after it is discovered.
Invoked on every out-edge of each vertex after it is discovered.
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on the back edges in the graph.
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on forward or cross edges in the graph.
(In an undirected graph this method is never called.)
Invoked on a vertex after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
Performs a undirected (depth first and height first) depth first
search on a directed bidirectional graph.
This algorithm is directly inspired from the
BoostGraphLibrary implementation.
Create a undirected dfs algorithm
Graph to search on.
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
vertex that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
vertex that raised the event
Computes the dfs
Computes the dfs starting at s
start vertex
Visits vertex s
vertex to visit
Registers the predecessors handler
Visited graph
Vertex color map
Edge color map
Invoked on every vertex of the graph before the start of the graph
search.
Invoked on the source vertex once before the start of the search.
Invoked when a vertex is encountered for the first time.
Invoked on every out-edge of each vertex after it is discovered.
Invoked on each edge as it becomes a member of the edges that form
the search tree. If you wish to record predecessors, do so at this
event point.
Invoked on the back edges in the graph.
Invoked on a vertex after all of its out edges have been added to
the search tree and all of the adjacent vertices have been
discovered (but before their out-edges have been examined).
Bellman Ford shortest path algorithm.
The Bellman-Ford algorithm solves the single-source shortest paths
problem for a graph with both positive and negative edge weights.
If you only need to solve the shortest paths problem for positive
edge weights, Dijkstra's algorithm provides a more efficient
alternative.
If all the edge weights are all equal to one then breadth-first search
provides an even more efficient alternative.
Builds a new Bellman Ford searcher.
The graph
Edge weights
Any argument is null
This algorithm uses the .
Raises the event.
vertex that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Computes all the shortest path from s to the oter vertices
Start vertex
Initializes the predecessor and distance map.
true if successful, false if there was a negative cycle.
s is null
Applies the Bellman Ford algorithm
Does not initialize the predecessor and distance map.
true if successful, false if there was a negative cycle.
Vertex color map
Invoked on each vertex in the graph before the start of the
algorithm.
Invoked on every edge in the graph |V| times.
Invoked when the distance label for the target vertex is decreased.
The edge that participated in the last relaxation for vertex v is
an edge in the shortest paths tree.
Invoked if the distance label for the target vertex is not
decreased.
Invoked during the second stage of the algorithm,
during the test of whether each edge was minimized.
If the edge is minimized then this function is invoked.
Invoked during the second stage of the algorithm,
during the test of whether each edge was minimized.
If the edge was not minimized, this function is invoked.
This happens when there is a negative cycle in the graph.
Constructed distance map
Constructed predecessor map
Edge weights
Directed Acyclic Graph single source shortest path algorithm.
This algorithm solves the single-source shortest-paths problem on a
weighted, directed acyclic graph (DAG).
This algorithm is more efficient for DAG's than either the
or
..
Use instead of this algorithm
when all edge weights are equal to one.
It is strongly inspired from the
Boost Graph Library implementation.
Builds a new Dagsearcher.
Acyclic graph
Edge weights
Any argument is null
This algorithm uses the .
Triggers the InitializeVertex event
Triggers the DiscoverVertex event
Triggers the ExamineVertex event
Triggers the ExamineEdge event
Triggers the EdgeRelaxed event
Triggers the EdgeNotRelaxed event
Triggers the FinishVertex event
Computes all the shortest path from s to the oter vertices
Start vertex
s is null
Visited graph
Vertex color map
Invoked on each vertex in the graph before the start of the
algorithm.
Invoked on vertex v when the edge (u,v) is examined and v is White.
Since a vertex is colored Gray when it is discovered, each
reachable vertex is discovered exactly once. This is also when the
vertex is inserted into the priority queue.
Invoked on a vertex as it is added to set S.
At this point we know that (p[u],u) is a shortest-paths tree
edge so d[u] = delta(s,u) = d[p[u]] + w(p[u],u).
Also, the distances of the examined vertices is monotonically increasing
d[u1] <= d[u2] <= d[un].
Invoked on each out-edge of a vertex immediately after it has
been added to set S.
invoked on edge (u,v) if d[u] + w(u,v) < d[v]. The edge (u,v)
that participated in the last relaxation for vertex v is an edge
in the shortest paths tree.
Invoked if the edge is not relaxed. .
Invoked on a vertex after all of its out edges have been examined.
Constructed distance map
Constructed predecessor map
Dijkstra shortest path algorithm.
This algorithm solves the single-source shortest-paths problem
on a weighted, directed for the case where all
edge weights are nonnegative. It is strongly inspired from the
Boost Graph Library implementation.
Use the Bellman-Ford algorithm for the case when some edge weights are
negative.
Use breadth-first search instead of Dijkstra's algorithm when all edge
weights are equal to one.
Builds a new Dijsktra searcher.
The graph
Edge weights
Any argument is null
This algorithm uses the .
Create a edge unary weight dictionary.
graph to map
Dictionary where each edge wheight is 1
Create a edge unary weight dictionary.
graph to map
Dictionary where each edge wheight is 1
Raises the event.
edge that raised the event
Raises the event.
edge that raised the event
Checks for edge relation.
Checks for edge relation.
Computes all the shortest path from s to the oter vertices
Start vertex
s is null
Register the predecessor handlers
visitor
Add event handlers to the corresponding events.
Distance recorder visitor
Visited graph
Vertex color map
Invoked on each vertex in the graph before the start of the
algorithm.
Invoked on vertex v when the edge (u,v) is examined and v is WHITE.
Since a vertex is colored GRAY when it is discovered, each
reachable vertex is discovered exactly once. This is also when the
vertex is inserted into the priority queue.
Invoked on a vertex as it is removed from the priority queue and
added to set S. At this point we know that (p[u],u) is a
shortest-paths tree edge so
d[u] = delta(s,u) = d[p[u]] + w(p[u],u).
Also, the distances of the examined vertices is monotonically
increasing d[u1] <= d[u2] <= d[un].
Invoked on each out-edge of a vertex immediately after it has
been added to set S.
invoked on edge (u,v) if d[u] + w(u,v) < d[v]. The edge (u,v)
that participated in the last relaxation for vertex v is an edge
in the shortest paths tree.
Invoked if the edge is not relaxed. .
Invoked on a vertex after all of its out edges have been examined.
Constructed distance map
Vertex priorithized queue. Used internally.
The QuickGraph.Algorithms.ShortestPath namespace contains
algorithms for solving shortest path problems.
Graph with positive edge weight should use the
.
If all the wieghts are
equal to 1, the
is more efficient to use.
If the weights can be negavite,
use the .
Computes the graph strong components.
This class compute the strongly connected
components of a directed graph using Tarjan's algorithm based on DFS.
Construct a strong component algorithm
graph to apply algorithm on
graph is null
Construct a strong component algorithm
graph to apply algorithm on
component map to record results
graph is null
Used internally
Used internally
Executes the algorithm
The output of the algorithm is recorded in the component property
Components, which will contain numbers giving the component ID
assigned to each vertex.
The number of components is the return value of the function.
Visited graph
Component map
Root map
Vertex discory times
Gets the number of strongly connected components in the graph
Number of strongly connected components
Summary description for BoundedReachabilityGame.
Summary description for Strategy.
A Strategy as defined in section 3 of the article.
A TestGraph as defined in the section 2 of the article.
Gets a value indicating if is in the state set.
vertex to test
true if is in the state set
Gets a value indicating if is in CP.
vertex to test
true if is in CP
Gets a probability associated to the
.
edge to test
Probability associated to
Gets a cost associated to the
.
edge to test
Cost associated to
Gets the underlying
graph representing the Finite State Machine.
instance representing
the fsm.
Get the state enumerable collection (V-CP).
State vertices enumerable collection.
Get the choice point enumerable collection (CP).
Choice point vertices enumerable collection.
The implements the algorithm from the article:
Optimal Strategies for Testing Nondeterministic Systems,
Lev Nachmanson Margus Veanes Wolfram Schulte
Nikolai Tillmann Wolfgang Grieskamp
Microsoft Research, One Microsoft Way, Redmond, WA
flevnach,margus,schulte,nikolait,wrwgg@microsoft.com
http://research.microsoft.com/users/schulte/Papers/OptimalStrategiesForTestingNondeterminsticSystems(ISSTA2004).pdf
Summary description for OptimalStrategy.
Optimal winning strategy calculation algorithm.
This algorithm is an implementation of the
http://research.microsoft.com/users/schulte/Papers/OptimalStrategiesForTestingNondeterminsticSystems(ISSTA2004).pdf
Summary description for PairPreOrderPerformanceComparer.
Summary description for ReachabilityStrategyCalculationAlgorithm.
Summary description for Strategy.
Topological sort of the graph.
The topological sort algorithm creates a linear ordering of the
vertices such that if edge (u,v) appears in the graph, then v comes
before u in the ordering.
The graph must be a directed acyclic graph
(DAG). The implementation consists mainly of a call to
.
This algorithm is directly inspired from the
BoostGraphLibrary implementation.
Builds a new sorter
Graph to sort
Builds a new sorter
Graph to sort
vertices list
Delegate event that detects cycle. .
DepthFirstSearch algorithm
Edge that produced the error
Will always throw an exception.
Delegate that adds the vertex to the vertex list. .
Computes the topological sort and stores it in the list.
Computes the topological sort and stores it in the list.
Vertex list that will contain the results
Visited vertex list
Sorted vertices list
Creates a transitive closure of the input graph
The core algorithm for Transitive Closure (TC) is inspired by the
Boost Graph Library implementation
and Nuutila, E's work "Efficient Transitive Closure Computation in
Large Digraphs".
Event is raised when a new
vertex is added to the TC graph.
It maps a vertex in the original graph to the corresponding vertex in
the TC graph
Event is rasied when an edge is added to the
TC graph
Transitive closure constructor
Graph whose transitive closre needs to be
computed
is a .
Raises the event.
Raises the event.
New edge that was added to the transitive closure graph
Compute the transitive closure and store it in the supplied graph 'tc'
Mutable Graph instance to store the transitive closure
is a .
Visited Graph
Map of vertex in Original graph to corresponding vertex in Transitive Closure
Invoked when a new vertex is added to the Transitive Closure graph
Invoked when a new edge is added to the transitive closure graph.
Encapsulates a vertex in the original graph and it's corresponding vertex in a transformation of the graph
constructor
Vertex in original graph
Equivalent Vertex in the transformation graph
Vertex in original graph
Equivalent Vertex in the transformation graph
Delegate to handle the TransformVertexEvent
Under construction
Construct an eulerian trail builder
Search a new path to add to the current circuit
start vertex
true if successfull, false otherwize
Looks for a new path to add to the current vertex.
true if found a new path, false otherwize
Computes the number of eulerian trail in the graph. If negative,
there is an eulerian circuit.
number of eulerian trails
Merges the temporary circuit with the current circuit
true if all the graph edges are in the circuit
Computes the eulerian trails
Adds temporary edges to the graph to make all vertex even.
Removes temporary edges
Computes the set of eulerian trails that traverse the edge set.
This method returns a set of disjoint eulerian trails. This set
of trails spans the entire set of edges.
Eulerian trail set
Computes a set of eulerian trail, starting at
that spans the entire graph.
This method computes a set of eulerian trail starting at
that spans the entire graph.The algorithm outline is as follows:
The algorithms iterates throught the Eulerian circuit of the augmented
graph (the augmented graph is the graph with additional edges to make
the number of odd vertices even).
If the current edge is not temporary, it is added to the current trail.
If the current edge is temporary, the current trail is finished and
added to the trail collection. The shortest path between the
start vertex and the target vertex of the
temporary edge is then used to start the new trail. This shortest
path is computed using the .
start vertex
eulerian trail set, all starting at s
s is a null reference.
Eulerian trail not computed yet.
Visited Graph
Eulerian circuit on modified graph
Used internally
The QuickGraph.Algorithms.Travelling namespace
contains classes for solving travelling problems such as
computing Eulerian trails, Chinese Postman (not yet), Travelling salesman (not yet).
Records the vertex distance
Default constructor
Uses the dictionary to record the distance
Distance dictionary
distances is null
d[u] = + intfy
Algorithm using the visitor
Contains the vertex
d[u] = 0;
Let e = (u,v), d[ v ] = d[ u ] + 1;
Vertex distance dictionary
Visitor that computes the edge predecessors.
Default constructor
Returns the path leading to the vertex v.
end of the path
path leading to v
Returns the minimal set of path from the entry point that
executes all actions
Create a merged path.
This method creates an edge path that stops if an edge is not white
or the edge has no more predecessors.
end edge
edge color dictionary
path to edge
Returns the array of merged paths
Not used
Records edge predecessor
Records end path edges
Vertex Edge predecessor map.
End path edges collection
A visitor that records edges.
Create an empty edge visitor
Record edge handler
Recorded edges
Scales the edge weights at each call
Constructs a edge weight scaler
edge weight dictionary
weight scale factor
Event handler that applies the factor the edge weight
event arguement containing the edge
Gets the edge weight dictionary
Edge weight dictionary
Gets or sets the scale factor
Scale factor
Visitor that records the sink vertices in the visited tree.
A sink vertex is a vertex that has no out-edges.
Create a instance.
visited graph
g is a null reference
Create a instance.
visited graph
collection that will hold the sinks
g is a null reference
Gets the visited instance
The visited graph
Gets the sink collection
A of sink vertices
The QuickGraph.Algorithms.Visitors namespace contains
classic graph algorithm visitors.
Visitor that computes the vertices predecessors.
The visitor applies to any algorithm that implements the
model.
This sample shows how to use the find the predecessor map using a
:
Graph g = ...;
// creating dfs algorithm
DepthFirstSearchAlgorithm dfs = new DepthFirstSearchAlgorithm(g);
// creating predecessor visitor
PredecessorVisitor pred = new PredecessorVisitor();
// registering event handlers
pred.RegisterHandlers(dfs);
//executing...
dfs.Compute();
// pred.Predecessors now contains the map of predecessors.
Default constructor
Constructor, uses the given predecessor map.
Predecessor map
predecessors is null
Returns the path leading to the vertex v.
end of the path
path leading to v
Returns the minimal set of path from the entry point that
executes all actions
Let e = (u,v), p[v]=u
Records end of path vertex
Vertex Edge predecessor map.
End of path vertices
Summary description for SuccessorRecorderVisitor.
Removes
Let e = (u,v), p[u]=e
Description résumée de TimeStamperVisitor.
Default constructor
Store the current time in the discover dictionary and increment
the current time.
Store the current time in the finish dictionary and increment
the current time.
Vertex discover time dictionary
Vertex finish time dictionary
Current time
Summary description for VertexListPopulatorVisitor.
A visitor that records vertices.
Create an empty vertex visitor
Record vertex handler
Record vertex handler
Record vertex handler
Recorded vertices