Bridges-Java-2.3.3
2.3.3
Bridges(JavaAPI)
|
The GraphAdjList class can be used to represent adjacency list based graphs in BRIDGES. More...
Public Member Functions | |
GraphAdjList () | |
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) |
E1 | getVertexData (K src) |
void | setEdgeData (K src, K dest, E2 edge_data) |
E2 | getEdgeData (K src, K dest) |
HashMap< K, Element< E1 > > | getVertices () |
Element< E1 > | getVertex (K key) |
HashMap< K, SLelement< Edge< K, E2 > > > | getAdjacencyList () |
SLelement< Edge< K, E2 > > | getAdjacencyList (K vertex) |
LinkVisualizer | getLinkVisualizer (K src, K dest) throws Exception |
ElementVisualizer | getVisualizer (K vertex) throws Exception |
String | getDataStructureRepresentation () |
![]() | |
abstract String | getDataStructType () |
Additional Inherited Members | |
![]() | |
String | QUOTE = "\"" |
The GraphAdjList class can be used to represent adjacency list based graphs in BRIDGES.
The GraphAdjList class can be used to represent adjacency list 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 adjacency lists, also a Java hashmap are built for each vertex and contain the edge (terminating vertex id, weight) in the Edge structure, defined separately. Adjacency lists are singly linked lists using the BRIDGES SLelement.
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> | holds vertex specific information, defined by application |
<E2> | holds edge specific information, defined by application |
http://bridgesuncc.github.io/Hello_World_Tutorials/Graph.html
bridges.base.GraphAdjList< K, E1, E2 >.GraphAdjList | ( | ) |
Constructor
void bridges.base.GraphAdjList< K, E1, E2 >.addEdge | ( | K | src, |
K | dest | ||
) |
Adds a new edge to the graph, adds it to that vertex's adjacency list; user is responsible for checking if the vertex already exists. This version assumes a default edge weight of 1.
src | - source vertex of edge |
dest | - destination vertex of edge |
void bridges.base.GraphAdjList< K, E1, E2 >.addEdge | ( | K | src, |
K | dest, | ||
int | weight | ||
) |
Adds a new edge to the graph, adds it to that vertex's adjacency list; user is responsible for checking if the vertex already exists.
src | - source vertex of edge |
dest | - destination vertex of edge |
weight | - edge weight |
void bridges.base.GraphAdjList< 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 id |
E | - vertex info, currently used as a label by default |
HashMap<K, SLelement<Edge<K, E2> > > bridges.base.GraphAdjList< K, E1, E2 >.getAdjacencyList | ( | ) |
Gets the adjacency list (of type SLelement<Edge> )
SLelement<Edge<K, E2> > bridges.base.GraphAdjList< K, E1, E2 >.getAdjacencyList | ( | K | vertex | ) |
String bridges.base.GraphAdjList< K, E1, E2 >.getDataStructType | ( | ) |
This method gets the data structure type
String bridges.base.GraphAdjList< K, E1, E2 >.getDataStructureRepresentation | ( | ) |
E2 bridges.base.GraphAdjList< 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.GraphAdjList< 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
Element<E1> bridges.base.GraphAdjList< K, E1, E2 >.getVertex | ( | K | key | ) |
This is a convenience method to retrieve a vertex given its key
return – graph vertex corresponding to its key
E1 bridges.base.GraphAdjList< K, E1, E2 >.getVertexData | ( | K | src | ) |
Gets data for an edge
src | - source vertex of edge |
dest | - destination vertex of edge |
HashMap<K, Element<E1> > bridges.base.GraphAdjList< K, E1, E2 >.getVertices | ( | ) |
This method returns the graph nodes
return – vertices held in in the hashmap
ElementVisualizer bridges.base.GraphAdjList< 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.GraphAdjList< K, E1, E2 >.setEdgeData | ( | K | src, |
K | dest, | ||
E2 | edge_data | ||
) |
Sets data for an edge
src | - source vertex of edge |
dest | - destination vertex of edge |
data | - edge data |
void bridges.base.GraphAdjList< K, E1, E2 >.setVertexData | ( | K | src, |
E1 | vertex_data | ||
) |
Sets data for a graph vertex
src | - source vertex of edge |
dest | - destination vertex of edge |
data | - vertex data |