SymbolGraph Class |
The SymbolGraph class represents an undirected graph, where the vertex names are arbitrary strings. By providing mappings between string vertex names and integers, it serves as a wrapper around the data type, which assumes the vertex names are integers between 0 and V - 1. It also supports initializing a symbol graph from a file.
This implementation uses an to map from strings to integers, an array to map from integers to strings, and a to store the underlying graph. The Index and Contains operations take time proportional to log V, where V is the number of vertices. The Name operation takes constant time.
Namespace: Algs4Net
public class SymbolGraph
The SymbolGraph type exposes the following members.
Name | Description | |
---|---|---|
![]() | SymbolGraph |
Initializes a graph from a file using the specified delimiter.
Each line in the file contains
the name of a vertex, followed by a list of the names
of the vertices adjacent to that vertex, separated by the delimiter. |
Name | Description | |
---|---|---|
![]() | G |
Returns the graph assoicated with the symbol graph. It is the client's responsibility
not to mutate the graph. |
Name | Description | |
---|---|---|
![]() | Contains |
Does the graph contain the vertex named s? |
![]() | Index |
Returns the integer associated with the vertex named s. |
![]() ![]() | MainTest |
Demo test the SymbolGraph data type. |
![]() | Name |
Returns the name of the vertex associated with the integer v. |
For additional documentation, see Section 4.1 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class SymbolGraph implementation by the respective authors.