Class BidirectionalMatrixGraph<TEdge>
Mutable bidirectional graph data structure based on a matrix.
Inheritance
Implements
Inherited Members
Namespace: QuikGraph
Assembly: QuikGraph.dll
Syntax
[Serializable]
public class BidirectionalMatrixGraph<TEdge> : IBidirectionalGraph<int, TEdge>, IVertexAndEdgeListGraph<int, TEdge>, IVertexListGraph<int, TEdge>, IBidirectionalIncidenceGraph<int, TEdge>, IIncidenceGraph<int, TEdge>, IImplicitGraph<int, TEdge>, IMutableEdgeListGraph<int, TEdge>, IMutableGraph<int, TEdge>, IEdgeListGraph<int, TEdge>, IGraph<int, TEdge>, IEdgeSet<int, TEdge>, IVertexSet<int>, IImplicitVertexSet<int>, ICloneable where TEdge : class, IEdge<int>
Type Parameters
Name | Description |
---|---|
TEdge | Edge type |
Constructors
| Improve this Doc View SourceBidirectionalMatrixGraph(Int32)
Initializes a new instance of the BidirectionalMatrixGraph<TEdge> class.
Declaration
public BidirectionalMatrixGraph(int vertexCount)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertexCount | Number of vertices. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException |
|
Properties
| Improve this Doc View SourceAllowParallelEdges
Gets a value indicating if the graph allows parallel edges
Declaration
public bool AllowParallelEdges { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
EdgeCount
Gets the edge count.
Declaration
public int EdgeCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Edges
Gets the edges.
Declaration
public IEnumerable<TEdge> Edges { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TEdge> |
IsDirected
Gets a value indicating if the graph is directed
Declaration
public bool IsDirected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsEdgesEmpty
Gets a value indicating whether there are no edges in this set. It is true if this edge set is empty, otherwise false.
Declaration
public bool IsEdgesEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsVerticesEmpty
Gets a value indicating whether there are no vertices in this set. It is true if this vertex set is empty, otherwise false.
Declaration
public bool IsVerticesEmpty { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
VertexCount
Gets the vertex count.
Declaration
public int VertexCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Vertices
Gets the vertices.
Declaration
public IEnumerable<int> Vertices { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
Methods
| Improve this Doc View SourceAddEdge(TEdge)
Adds the edge
to this graph.
Declaration
public bool AddEdge(TEdge edge)
Parameters
Type | Name | Description |
---|---|---|
TEdge | edge | An edge. |
Returns
Type | Description |
---|---|
System.Boolean | True if the edge was added, false otherwise. |
Exceptions
Type | Condition |
---|---|
ParallelEdgeNotAllowedException |
|
AddEdgeRange(IEnumerable<TEdge>)
Adds a set of edges to this graph.
Declaration
public int AddEdgeRange(IEnumerable<TEdge> edges)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<TEdge> | edges | Edges to add. |
Returns
Type | Description |
---|---|
System.Int32 | The number of edges successfully added to this graph. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Clear()
Clears the vertex and edges.
Declaration
public void Clear()
ClearEdges(Int32)
Clears the in-edges and out-edges of the given vertex
.
Declaration
public void ClearEdges(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | The vertex. |
ClearInEdges(Int32)
Clears the in-edges of the given vertex
.
Declaration
public void ClearInEdges(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | The vertex. |
ClearOutEdges(Int32)
Clears the out-edges of the given vertex
Declaration
public void ClearOutEdges(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | The vertex. |
Clone()
Clones this graph.
Declaration
public BidirectionalMatrixGraph<TEdge> Clone()
Returns
Type | Description |
---|---|
BidirectionalMatrixGraph<TEdge> | Cloned graph. |
ContainsEdge(TEdge)
Determines whether this set contains the specified edge
.
Declaration
public bool ContainsEdge(TEdge edge)
Parameters
Type | Name | Description |
---|---|---|
TEdge | edge | Edge to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
ContainsEdge(Int32, Int32)
Checks if this graph contains an edge that link
source
and target
vertices.
Declaration
public bool ContainsEdge(int source, int target)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | source | |
System.Int32 | target |
Returns
Type | Description |
---|---|
System.Boolean | True if an edge exists, false otherwise. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
ContainsVertex(Int32)
Determines whether this set contains the specified vertex
.
Declaration
public bool ContainsVertex(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Boolean | True if the specified |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Degree(Int32)
Gets the degree of vertex
, i.e.
the sum of the out-degree and in-degree of vertex
.
Declaration
public int Degree(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Int32 | The sum of OutDegree and InDegree of |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
VertexNotFoundException |
|
InDegree(Int32)
Gets the number of in-edges of vertex
.
Declaration
public int InDegree(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Int32 | The number of in-edges pointing towards |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
VertexNotFoundException |
|
InEdge(Int32, Int32)
Gets the in-edge at location index
.
Declaration
public TEdge InEdge(int vertex, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | |
System.Int32 | index | The index. |
Returns
Type | Description |
---|---|
TEdge | The in-edge at position |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException | No vertex at |
VertexNotFoundException |
|
InEdges(Int32)
Gets the collection of in-edges of vertex
.
Declaration
public IEnumerable<TEdge> InEdges(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TEdge> | The collection of in-edges of |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
VertexNotFoundException |
|
IsInEdgesEmpty(Int32)
Determines whether vertex
has no in-edges.
Declaration
public bool IsInEdgesEmpty(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
VertexNotFoundException |
|
IsOutEdgesEmpty(Int32)
Determines whether there are out-edges associated to vertex
.
Declaration
public bool IsOutEdgesEmpty(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
VertexNotFoundException |
|
OnEdgeAdded(TEdge)
Called on each added edge.
Declaration
protected virtual void OnEdgeAdded(TEdge edge)
Parameters
Type | Name | Description |
---|---|---|
TEdge | edge | Added edge. |
OnEdgeRemoved(TEdge)
Called on each removed edge.
Declaration
protected virtual void OnEdgeRemoved(TEdge edge)
Parameters
Type | Name | Description |
---|---|---|
TEdge | edge | Removed edge. |
OutDegree(Int32)
Gets the count of out-edges of vertex
.
Declaration
public int OutDegree(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Int32 | The count of out-edges of |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
VertexNotFoundException |
|
OutEdge(Int32, Int32)
Gets the out-edge of vertex
at position index
.
Declaration
public TEdge OutEdge(int vertex, int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | |
System.Int32 | index | The index. |
Returns
Type | Description |
---|---|
TEdge | The out-edge at position |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentOutOfRangeException | No vertex at |
VertexNotFoundException |
|
OutEdges(Int32)
Gets the out-edges of vertex
.
Declaration
public IEnumerable<TEdge> OutEdges(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TEdge> | An enumeration of the out-edges of |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
VertexNotFoundException |
|
RemoveEdge(TEdge)
Removes the edge
from this graph.
Declaration
public bool RemoveEdge(TEdge edge)
Parameters
Type | Name | Description |
---|---|---|
TEdge | edge | Edge to remove. |
Returns
Type | Description |
---|---|
System.Boolean | True if the |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
RemoveEdgeIf(EdgePredicate<Int32, TEdge>)
RemoveEdgeIf(EdgePredicate<Int32, TEdge>) is not implemented for this kind of graph.
Declaration
public int RemoveEdgeIf(EdgePredicate<int, TEdge> predicate)
Parameters
Type | Name | Description |
---|---|---|
EdgePredicate<System.Int32, TEdge> | predicate |
Returns
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | This method is not supported. |
RemoveInEdgeIf(Int32, EdgePredicate<Int32, TEdge>)
Removes in-edges of the given vertex
that match
predicate predicate
.
Declaration
public int RemoveInEdgeIf(int vertex, EdgePredicate<int, TEdge> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | The vertex. |
EdgePredicate<System.Int32, TEdge> | predicate | Edge predicate. |
Returns
Type | Description |
---|---|
System.Int32 | Number of edges removed. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
RemoveOutEdgeIf(Int32, EdgePredicate<Int32, TEdge>)
Removes all out-edges of the vertex
where the predicate
is evaluated to true.
Declaration
public int RemoveOutEdgeIf(int vertex, EdgePredicate<int, TEdge> predicate)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | The vertex. |
EdgePredicate<System.Int32, TEdge> | predicate | Predicate to remove edges. |
Returns
Type | Description |
---|---|
System.Int32 | The number of removed edges. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
TryGetEdge(Int32, Int32, out TEdge)
Tries to get the edge that link
source
and target
vertices.
Declaration
public bool TryGetEdge(int source, int target, out TEdge edge)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | source | |
System.Int32 | target | |
TEdge | edge | Edge found, otherwise null. |
Returns
Type | Description |
---|---|
System.Boolean | True if an edge was found, false otherwise. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
TryGetEdges(Int32, Int32, out IEnumerable<TEdge>)
Tries to get edges that link
source
and target
vertices.
Declaration
public bool TryGetEdges(int source, int target, out IEnumerable<TEdge> edges)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | source | |
System.Int32 | target | |
System.Collections.Generic.IEnumerable<TEdge> | edges | Edges found, otherwise null. |
Returns
Type | Description |
---|---|
System.Boolean | True if at least an edge was found, false otherwise. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
System.ArgumentNullException |
|
TryGetInEdges(Int32, out IEnumerable<TEdge>)
Tries to get the in-edges of vertex
.
Declaration
public bool TryGetInEdges(int vertex, out IEnumerable<TEdge> edges)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | |
System.Collections.Generic.IEnumerable<TEdge> | edges | In-edges. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
TryGetOutEdges(Int32, out IEnumerable<TEdge>)
Tries to get the out-edges of vertex
.
Declaration
public bool TryGetOutEdges(int vertex, out IEnumerable<TEdge> edges)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex | |
System.Collections.Generic.IEnumerable<TEdge> | edges | Out-edges. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
Events
| Improve this Doc View SourceEdgeAdded
Fired when an edge is added to this graph.
Declaration
public event EdgeAction<int, TEdge> EdgeAdded
Event Type
Type | Description |
---|---|
EdgeAction<System.Int32, TEdge> |
EdgeRemoved
Fired when an edge has been removed from this graph.
Declaration
public event EdgeAction<int, TEdge> EdgeRemoved
Event Type
Type | Description |
---|---|
EdgeAction<System.Int32, TEdge> |
Explicit Interface Implementations
| Improve this Doc View SourceICloneable.Clone()
Declaration
object ICloneable.Clone()
Returns
Type | Description |
---|---|
System.Object |