Bridges-Java
3.4.3
Bridges(Java API)
|
The GraphAdjMatrix class can be used to represent adjacency matrix based graphs in BRIDGES.
The GraphAdjMatrix class can be used to represent adjacency matrix based graphs in BRIDGES; it takes 2 generic parameters: (1) K, which is an orderable key value used in accessing vertices (in constant time) using a hashmap. This permits data sets that need to be accessed by keys that are strings, and (2) E, an application defined type, and used in the Edge representation. The class is simply a wrapper around the Java Hashmap class and, thus, derives all its operations from it. BRIDGES provides methods to visualize the graph and its contents.
The vertices of the graph are held in a Java hashmap, for near constant time access; this lets us use strings or integral ids for vertices. The edges are accessed by a second hashmap from each vertex, again assuring near constant access time. Each edge contains the terminating vertex id and weight, as defined by the Edge class structure.
Convenience methods are provided to add vertices and edges to the graph. Edges are retrieved by using the dual hashmap, given the vertex ids of the edge. Methods to access the element and link visualizer are now provided, indexed vertex ids, making it easier to set visual attributes to graph nodes and links.
K | orderable key (string, int, etc) that is used to index into vertex |
E1 | vertex specific information, for graph vertices |
E2 | edge specific information, for graph vertices |
Public Member Functions | |
GraphAdjMatrix () | |
String | getDataStructType () |
void | addVertex (K k, E1 e) |
void | addEdge (K src, K dest) |
void | addEdge (K src, K dest, int weight) |
void | setVertexData (K src, E1 vertex_data) |
Sets data for a graph vertex. More... | |
E1 | getVertexData (K src) |
void | setEdgeData (K src, K dest, E2 data) |
E2 | getEdgeData (K src, K dest) |
HashMap< K, Element< E1 > > | getVertices () |
HashMap< K, HashMap< K, Integer > > | getAdjacencyMatrix () |
HashMap< K, Integer > | getAdjacencyMatrix (K key) |
LinkVisualizer | getLinkVisualizer (K src, K dest) throws Exception |
ElementVisualizer | getVisualizer (K vertex) throws Exception |
String | getDataStructureRepresentation () |
Additional Inherited Members | |
Protected Attributes inherited from bridges.base.DataStruct | |
String | QUOTE = "\"" |
Package Attributes inherited from bridges.base.DataStruct | |
String | COMMA = "," |
String | COLON = ":" |
String | OPEN_CURLY = "{" |
String | CLOSE_CURLY = "}" |
String | OPEN_PAREN = "(" |
String | CLOSE_PAREN = ")" |
String | OPEN_BOX = "[" |
String | CLOSE_BOX = "]" |
bridges.base.GraphAdjMatrix< K, E1, E2 >.GraphAdjMatrix | ( | ) |
Constructor
void bridges.base.GraphAdjMatrix< K, E1, E2 >.addEdge | ( | K | src, |
K | dest | ||
) |
Adds a new edge to the graph, adds it to the index corresponding to the source, destination vertex ids; this version of the method assumes an edge weight of 1 (unweighted graph); user is responsible for checking if the vertices already exist, else an exception is thrown.
src | - source vertex of edge |
dest | - destination vertex of edge |
void bridges.base.GraphAdjMatrix< K, E1, E2 >.addEdge | ( | K | src, |
K | dest, | ||
int | weight | ||
) |
Adds a new edge of weight 'weight' to the graph, adds it to the index corresponding to the source, destination vertex ids; user is responsible for checking if the vertices already exist, else an exception is thrown.
src | - source vertex of edge |
dest | - destination vertex of edge |
weight | - edge weight |
void bridges.base.GraphAdjMatrix< K, E1, E2 >.addVertex | ( | K | k, |
E1 | e | ||
) |
Adds a new vertex to the graph, initializes the adjacency list; user is responsible for checking if the vertex already exists. This method will replace the value for this key
k | - vertex key value |
e | - user specified data, part of the vertex data |
HashMap<K, HashMap<K, Integer> > bridges.base.GraphAdjMatrix< K, E1, E2 >.getAdjacencyMatrix | ( | ) |
Gets the adjacency matrix
HashMap<K, Integer> bridges.base.GraphAdjMatrix< K, E1, E2 >.getAdjacencyMatrix | ( | K | key | ) |
Gets the row of the adjacency matrix corresponding to the key
key | key value |
String bridges.base.GraphAdjMatrix< K, E1, E2 >.getDataStructType | ( | ) |
This method gets the data structure type
Reimplemented from bridges.base.DataStruct.
String bridges.base.GraphAdjMatrix< K, E1, E2 >.getDataStructureRepresentation | ( | ) |
Reimplemented from bridges.base.DataStruct.
E2 bridges.base.GraphAdjMatrix< K, E1, E2 >.getEdgeData | ( | K | src, |
K | dest | ||
) |
Gets data for an edge
src | - source vertex of edge |
dest | - destination vertex of edge |
LinkVisualizer bridges.base.GraphAdjMatrix< K, E1, E2 >.getLinkVisualizer | ( | K | src, |
K | dest | ||
) | throws Exception |
This is a convenience method to simplify access to the link visualizer; the method assumes the vertex names point to existing vertices, else an exception is thrown
E1 bridges.base.GraphAdjMatrix< K, E1, E2 >.getVertexData | ( | K | src | ) |
Gets data for a vertex
src | source vertex of edge |
HashMap<K, Element<E1> > bridges.base.GraphAdjMatrix< K, E1, E2 >.getVertices | ( | ) |
This method returns the graph nodes
return – vertices held in an unordered map
ElementVisualizer bridges.base.GraphAdjMatrix< K, E1, E2 >.getVisualizer | ( | K | vertex | ) | throws Exception |
This is a convenience method to simplify access to the element visualizer; the method assumes the vertex name points to an existing vertice, else an exception is thrown
void bridges.base.GraphAdjMatrix< K, E1, E2 >.setEdgeData | ( | K | src, |
K | dest, | ||
E2 | data | ||
) |
Sets data for an edge
src | - source vertex of edge |
dest | - destination vertex of edge |
data | - edge data |
void bridges.base.GraphAdjMatrix< K, E1, E2 >.setVertexData | ( | K | src, |
E1 | vertex_data | ||
) |
Sets data for a graph vertex.
src | source vertex of edge |
vertex_data | vertex data |