AdjMatrixEdgeWeightedDigraph Class |
The AdjMatrixEdgeWeightedDigraph class represents a edge-weighted digraph of vertices named 0 through V - 1, where each directed edge is of type and has a real-valued weight. It supports the following two primary operations: add a directed edge to the digraph and iterate over all of edges incident from a given vertex. It also provides methods for returning the number of vertices V and the number of edges E. Parallel edges are disallowed; self-loops are permitted.
This implementation uses an adjacency-matrix representation. All operations take constant time (in the worst case) except iterating over the edges incident from a given vertex, which takes time proportional to V.
Namespace: Algs4Net
public class AdjMatrixEdgeWeightedDigraph
The AdjMatrixEdgeWeightedDigraph type exposes the following members.
Name | Description | |
---|---|---|
![]() | AdjMatrixEdgeWeightedDigraph(Int32) |
Initializes an empty edge-weighted digraph with V vertices and 0 edges. |
![]() | AdjMatrixEdgeWeightedDigraph(TextInput) |
Initializes an edge-weighted digraph from a text input stream.
The format is the number of vertices V,
followed by the number of edges E,
followed by E pairs of vertices and edge weights,
with each entry separated by whitespace. |
![]() | AdjMatrixEdgeWeightedDigraph(Int32, Int32) |
Initializes a random edge-weighted digraph with V vertices and E edges. |
Name | Description | |
---|---|---|
![]() | E |
Returns the number of edges in the edge-weighted digraph. |
![]() | V |
Returns the number of vertices in the edge-weighted digraph. |
Name | Description | |
---|---|---|
![]() | AddEdge |
Adds the directed edge e to the edge-weighted digraph (if there
is not already an edge with the same endpoints). |
![]() | Adj |
Returns the directed edges incident from vertex v. |
![]() ![]() | MainTest |
Demo test the AdjMatrixEdgeWeightedDigraph data type. |
![]() | ToString |
Returns a string representation of the edge-weighted digraph. This method takes
time proportional to V2. (Overrides ObjectToString.) |
For additional documentation, see Section 4.4 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class AdjMatrixEdgeWeightedDigraph implementation by the respective authors.