Bridges-Java
3.4.3
Bridges(Java API)
|
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 3 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, (2) E1, for maintaining vertex specific data, and (3) E2, for maintaining edge specific data. The class is 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.
In most cases, you want all the three types to be the same, or in cases where you only care about the vertex key type, one can use the GraphAdjListSimple helper class.
The vertices of the graph are held in a Java hashmap, for near constant time access; this enables to use strings or integer ids for vertices. The adjacency lists, also a Java hashmap are built for each vertex and contain the edge (source, destination vertices) in the Edge structure, defined separately.
Convenience method addVertex() is provided to add vertices to the graph, and addEdge() is provided to add edges. Edges are retrieved by using the dual hashmap, given the vertex ids of the edge. Vertices can be styled directly from the vertex element returned by getVertex(), and edges are styled from a LinkVisualizer one can access through getLinkVisualizer(). Here is a simple example:
Adjacency lists are singly linked lists using the BRIDGES SLelement. Iterators are provided for easy traversal of the adjacency lists. For instance,
Graphs can have their nodes and links affected by visual attributes. Nodes can have color, size, opacity and shape and detailed in the ElementVisualizer class. Edges support attributes such as color, thickness and opacity and are detailed in the LinkVisualizer class. Element and link attributes are set using the getVisualizer() and getLinkVisualizer() methods. For instance,
There are two visualization engines available for graph. The small graph visualization supports all attributes of vertices and edges but is prohibitively slow on large graphs. The large graph visualization only supports locations (actually they are mandatory) and colors, all other attributes are ignored.
BRIDGES picks the rendering engine automatically. But it can be forced to pick one used forceLargeVizualization() and forceSmallVizualization
K | orderable key (String, Integer, etc) that is used to index into vertex |
E1 | holds vertex specific information, defined by application |
E2 | holds edge specific information, defined by application |
Public Member Functions | |
GraphAdjList () | |
String | getDataStructType () |
This method gets the data structure type. More... | |
void | addVertex (K k, E1 e) |
adds a new vertex to the graph. More... | |
void | addEdge (K src, K dest) |
adds a new edge to the graph. More... | |
void | addEdge (K src, K dest, E2 data) |
adds a new edge to the graph. More... | |
void | setVertexData (K src, E1 vertex_data) |
Sets data for a graph vertex. More... | |
E1 | getVertexData (K src) |
Gets data for an edge. More... | |
void | setEdgeData (K src, K dest, E2 edge_data) |
Sets data for an edge. More... | |
E2 | getEdgeData (K src, K dest) |
Gets data for an edge. More... | |
HashMap< K, Element< E1 > > | getVertices () |
This method returns the graph vertices. More... | |
Element< E1 > | getVertex (K key) |
returns a vertex from its key More... | |
HashMap< K, SLelement< Edge< K, E2 > > > | getAdjacencyList () |
Gets the graph's adjacency list. More... | |
SLelement< Edge< K, E2 > > | getAdjacencyList (K vertex) |
Gets the adjacency list of a vertex. Note that the list can be traversed using iterators. See example at top of page. More... | |
Iterable< Edge< K, E2 > > | outgoingEdgeSetOf (K vertex) |
returns an iterable set of outgoing edge of a vertex More... | |
LinkVisualizer | getLinkVisualizer (K src, K dest) |
Access a LinkVisualizer associated with an edge. More... | |
ElementVisualizer | getVisualizer (K vertex) |
Access the ElementVisualizer associated with a vertex. More... | |
void | forceLargeVisualization (boolean f) |
Forces the graph use the large graph visualization. More... | |
void | forceSmallVisualization (boolean f) |
Forces the graph to use the small graph visualization. More... | |
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.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 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 the edge data is null.
src | - source vertex of edge |
dest | - destination vertex of edge |
void bridges.base.GraphAdjList< K, E1, E2 >.addEdge | ( | K | src, |
K | dest, | ||
E2 | data | ||
) |
adds a new edge to the graph.
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 |
data | - edge data |
void bridges.base.GraphAdjList< K, E1, E2 >.addVertex | ( | K | k, |
E1 | e | ||
) |
adds a new vertex to the graph.
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 |
void bridges.base.GraphAdjList< K, E1, E2 >.forceLargeVisualization | ( | boolean | f | ) |
Forces the graph use the large graph visualization.
This forces the rendering to a more bandwidth efficient at the cost of having less features. The large graph visualization only renders vertices that have specified locations. The only usable attribute for vertices and edges are colors.
f | true to force large visualization. Setting to false does not prevent large visualization to be used, just does not force it. |
void bridges.base.GraphAdjList< K, E1, E2 >.forceSmallVisualization | ( | boolean | f | ) |
Forces the graph to use the small graph visualization.
The small visualization uses more bandwidth, have more features, and support a force directed layout for vertices which do not have a specified location.
f | true to force using the small visualization. Setting to false does not prevent small visualization to be used, just does not force it. |
HashMap<K, SLelement<Edge<K, E2> > > bridges.base.GraphAdjList< K, E1, E2 >.getAdjacencyList | ( | ) |
Gets the graph's adjacency list.
SLelement<Edge<K, E2> > bridges.base.GraphAdjList< K, E1, E2 >.getAdjacencyList | ( | K | vertex | ) |
Gets the adjacency list of a vertex. Note that the list can be traversed using iterators. See example at top of page.
vertex | the key of the vertex |
String bridges.base.GraphAdjList< K, E1, E2 >.getDataStructType | ( | ) |
This method gets the data structure type.
Reimplemented from bridges.base.DataStruct.
String bridges.base.GraphAdjList< K, E1, E2 >.getDataStructureRepresentation | ( | ) |
Reimplemented from bridges.base.DataStruct.
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 | ||
) |
Access a LinkVisualizer associated with an edge.
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
src | source vertex |
dest | destination vertex |
Element<E1> bridges.base.GraphAdjList< K, E1, E2 >.getVertex | ( | K | key | ) |
returns a vertex from its key
This is a convenience method to retrieve a vertex given its key
E1 bridges.base.GraphAdjList< K, E1, E2 >.getVertexData | ( | K | src | ) |
Gets data for an edge.
src | - source vertex of edge |
HashMap<K, Element<E1> > bridges.base.GraphAdjList< K, E1, E2 >.getVertices | ( | ) |
This method returns the graph vertices.
ElementVisualizer bridges.base.GraphAdjList< K, E1, E2 >.getVisualizer | ( | K | vertex | ) |
Access the ElementVisualizer associated with a vertex.
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
vertex | graph vertex |
Iterable<Edge<K, E2> > bridges.base.GraphAdjList< K, E1, E2 >.outgoingEdgeSetOf | ( | K | vertex | ) |
returns an iterable set of outgoing edge of a vertex
Gets a vector of the outgoing edges from a graph vertex
vertex | vertex identifier |
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 |
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 |
vertex_data | vertex data |