Click or drag to resize

GraphBaseTVertex, TEdge Class

abstract base class for graphs. It can handle non-directed and directed graphs. A directed edge from A to B means that A has a connection with B, but B doesn't have a connection with A.
Inheritance Hierarchy

Namespace:  SD.Tools.Algorithmia.Graphs
Assembly:  SD.Tools.Algorithmia (in SD.Tools.Algorithmia.dll) Version: 1.4.0.0 (1.4.19.0529)
Syntax
public abstract class GraphBase<TVertex, TEdge>
where TEdge : class, Object, IEdge<TVertex>

Type Parameters

TVertex
The type of the vertices in this graph.
TEdge
The type of the edges in the graph

The GraphBaseTVertex, TEdge type exposes the following members.

Constructors
  NameDescription
Protected methodGraphBaseTVertex, TEdge(Boolean)
Initializes a new instance of the GraphBaseTVertex, TEdge class.
Protected methodGraphBaseTVertex, TEdge(Boolean, Boolean)
Initializes a new instance of the GraphBaseTVertex, TEdge class.
Protected methodGraphBaseTVertex, TEdge(GraphBaseTVertex, TEdge, Boolean)
Copy constructor of the GraphBaseTVertex, TEdge class.
Protected methodGraphBaseTVertex, TEdge(Boolean, Boolean, Boolean)
Initializes a new instance of the GraphBaseTVertex, TEdge class.
Protected methodGraphBaseTVertex, TEdge(GraphBaseTVertex, TEdge, Boolean, Boolean)
Copy constructor of the GraphBaseTVertex, TEdge class.
Protected methodGraphBaseTVertex, TEdge(GraphBaseTVertex, TEdge, Boolean, Boolean, Boolean)
Copy constructor of the GraphBaseTVertex, TEdge class.
Top
Properties
  NameDescription
Public propertyEdgeCount
Returns the number of edges in this graph. If this graph is a directed graph, it counts the edge A to B as an edge, but B to A, if not present, isn't counted. A non-directed graph has an edge between A and B but also between B and A. This is counted as 1 edge, not two.
Public propertyEdgeProducerFunc
Gets or sets the edge producer func which produces edges for this graph. Used in some algorithms which have to produce edges.
Public propertyEdges
Returns the edges in this graph. Enumerating this property will enumerate the inner structures of the graph, no copy is made. This requires a lock on SyncRoot if IsSynchronized is set to true to make sure enumeration of this property is thread safe.
Public propertyIsDirected
if true, the graph is directed and only EdgeBase instances which have IsDirected set to true are allowed, otherwise it's a non-directed graph and EdgeBase instances which have IsDirected set to false are accepted.
Public propertyIsSynchronized
Gets a value indicating whether access to the Vertices and Edges is synchronized (thread safe). Default: false. Set to true to in the ctor to make sure the operations on this object are using locks. Use SyncRoot to lock on the same object as this class' internal operations.
Public propertyRemoveOrphanedVerticesOnEdgeRemoval
Gets or sets a value indicating whether vertices which are not part of any edge anymore are removed from the graph when the edge they're part of is removed from the graph (so they effectively are orphaned). Default is false.
Protected propertySuppressEvents
Gets or sets a value indicating whether events are blocked from being raised (true) or not (false, default)
Public propertySyncRoot
Gets an object that can be used to synchronize access to the Vertices and Edges properties. It's the same object used in locks inside this object.
Public propertyVertexCount
Returns the number of vertices in this graph.
Public propertyVertices
Returns the vertices in this graph. Enumerating this property will enumerate the inner structures of the graph, no copy is made. This requires a lock on SyncRoot if IsSynchronized is set to true to make sure enumeration of this property is thread safe.
Top
Methods
  NameDescription
Public methodAdd(TEdge)
Adds the provided edge to this graph. If the vertex(s) are not yet in this graph, it/they are added as well.
Public methodAdd(TVertex)
Adds the provided vertex to this graph.
Public methodAdd(GraphBaseTVertex, TEdge)
Adds all elements (i.e. vertices and edges) from the provided graph to this graph.
Public methodStatic memberComposeTGraph
Returns a composition of the two provided graphs. See http://en.wikipedia.org/wiki/Lexicographic_product_of_graphs.
Public methodContains(TEdge)
Determines whether this graph contains the edge object specified.
Public methodContains(TVertex)
Returns whether a vertex exists in this graph.
Public methodContainsEdge
Returns whether an edge exists in this graph between the start vertex and the end vertex specified.
Public methodDisconnect
Removes all edges from this graph between startVertex and endVertex. It will only remove edges between startVertex and endVertex, not between endVertex and startVertex, unless bothSides is set to true, then all edges between both vertices are removed, discarding their direction.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAdjacencyListForVertex
Gets the adjacency list for vertex. The adjacency list is a list of TVertex - Hashset(Of TEdge) tuples, as a vertex can have multiple edges with the same related vertex.
Public methodGetAsNonDirectedCopy
Creates a NonDirectedGraph version of this graph. Always creates a copy, even if this graph is a non-directed graph.
Public methodGetEdges
Gets all the edges between startVertex and endVertex.
Public methodGetEdgesFromStartVertex
Gets all the edges started from the startvertex specified.
Public methodGetEdgesSyncedAsList
Gets the edges as list, and perform this operation synced with the SyncRoot, to avoid threading issues.
Public methodGetEdgesToEndVertex
Gets all the edges which end in the endVertex specified.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetOrphanedVertices
Gets the orphaned vertices. Orphaned vertices are vertices which are not part of any edge in the graph
Public methodGetSubGraphTGraph
Gets a subgraph from this graph with the vertices and edges which match the functions specified. It creates a new instance and places the same vertex and edge instances in that graph.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetVerticesSyncedAsList
Gets the vertices as list, and perform this operation synced with the SyncRoot, to avoid threading issues.
Public methodIsConnected
A graph is called connected if every pair of distinct vertices in the graph is connected (directly or indirectly). A connected component is a maximal connected subgraph of G. Each vertex belongs to exactly one connected component, as does each edge. A directed graph is called weakly connected if replacing all of its directed edges with undirected edges produces a connected (undirected) graph. It is strongly connected or strong if it contains a directed path from u to v and a directed path from v to u for every pair of vertices u,v. The strong components are the maximal strongly connected subgraphs. See http://en.wikipedia.org/wiki/Connectivity_(graph_theory) We will only check for a connected un-directed graph or a weakly connected directed graph (same logic).
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnEdgeAdded
Called when an edge has been added
Protected methodOnEdgeAdding
Called when an edge is about to be added
Protected methodOnEdgeRemoved
Called when an edge has been removed
Protected methodOnEdgeRemoving
Called when an edge is about to be removed
Protected methodOnVertexAdded
Called when a vertex has been added
Protected methodOnVertexAdding
Called when a vertex is about to be added
Protected methodOnVertexRemoved
Called when a vertex has been removed
Protected methodOnVertexRemoving
Called when a vertex is about to be removed
Protected methodPerformSyncedAction(Action)
Performs the specified action, either inside a lock on SyncRoot if this graph is Synchronized, or normally, if the graph isn't synchronized.
Protected methodPerformSyncedActionT(FuncT)
Performs the specified action, either inside a lock on SyncRoot if this graph is Synchronized, or normally, if the graph isn't synchronized.
Public methodRemove(TEdge)
Removes the provided edge from the graph.
Public methodRemove(TVertex)
Removes a vertex from this graph.
Public methodRemove(GraphBaseTVertex, TEdge)
Removes all elements (i.e. vertices and edges) of the provided graph from this graph.
Public methodRemove(GraphBaseTVertex, TEdge, Boolean)
Removes all elements (i.e. vertices and/or edges) of the provided graph from this graph.
Public methodToString
Returns a String that represents the current Object.
(Overrides ObjectToString.)
Protected methodValidateEdgeForAddition
Validates if the edge passed in is addable to this graph structure. The start vertex and the end vertex for the are given as well. The same edge is present between startVertex and endVertex and also between endVertex and startVertex if the graph is a nondirected graph, hence the necessity of these two vertices in this routine
Protected methodValidateEdgeForRemoval
Validates if the edge passed in is removable from this graph structure. The start vertex and the end vertex for the are given as well. The same edge is present between startVertex and endVertex and also between endVertex and startVertex if the graph is a nondirected graph, hence the necessity of these two vertices in this routine
Protected methodValidateVertexForAddition
Validates if the vertex passed in is addable to this graph structure.
Protected methodValidateVertexForRemoval
Validates if the vertex passed in is removable from this graph structure.
Protected methodValidateVertexFromRemovalFromAdjacencyList
Validates if the vertexToRemove passed in is removable from the adjacency list of the vertex vertex. Removing the vertex means all edges from vertex to vertexToRemove are physically removed from the graph structure.
Top
Events
  NameDescription
Public eventEdgeAdded
Event which is raised when an edge has been added
Public eventEdgeAdding
Event which is raised when an edge is about to be added
Public eventEdgeRemoved
Event which is raised when an edge has been removed
Public eventEdgeRemoving
Event which is raised when an edge is about to be removed
Public eventVertexAdded
Event which is raised when a vertex has been added
Public eventVertexAdding
Event which is raised when a vertex is about to be added.
Public eventVertexRemoved
Event which is raised when a vertex has been removed
Public eventVertexRemoving
Event which is raised when a vertex is about to be removed
Top
See Also