Click or drag to resize
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.

Inheritance Hierarchy
SystemObject
  Algs4NetAdjMatrixEdgeWeightedDigraph

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class AdjMatrixEdgeWeightedDigraph

The AdjMatrixEdgeWeightedDigraph type exposes the following members.

Constructors
  NameDescription
Public methodAdjMatrixEdgeWeightedDigraph(Int32)
Initializes an empty edge-weighted digraph with V vertices and 0 edges.
Public methodAdjMatrixEdgeWeightedDigraph(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.
Public methodAdjMatrixEdgeWeightedDigraph(Int32, Int32)
Initializes a random edge-weighted digraph with V vertices and E edges.
Top
Properties
  NameDescription
Public propertyE
Returns the number of edges in the edge-weighted digraph.
Public propertyV
Returns the number of vertices in the edge-weighted digraph.
Top
Methods
  NameDescription
Public methodAddEdge
Adds the directed edge e to the edge-weighted digraph (if there is not already an edge with the same endpoints).
Public methodAdj
Returns the directed edges incident from vertex v.
Public methodStatic memberMainTest
Demo test the AdjMatrixEdgeWeightedDigraph data type.
Public methodToString
Returns a string representation of the edge-weighted digraph. This method takes time proportional to V2.
(Overrides ObjectToString.)
Top
Remarks

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.

See Also