Bridges-Java-2.3.3  2.3.3
Bridges(JavaAPI)
Public Member Functions | List of all members
bridges.base.GraphAdjList< K, E1, E2 > Class Template Reference

The GraphAdjList class can be used to represent adjacency list based graphs in BRIDGES. More...

Inheritance diagram for bridges.base.GraphAdjList< K, E1, E2 >:
bridges.base.DataStruct

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 ()
 
- Public Member Functions inherited from bridges.base.DataStruct
abstract String getDataStructType ()
 

Additional Inherited Members

- Protected Attributes inherited from bridges.base.DataStruct
String QUOTE = "\""
 

Detailed Description

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.

Author
Kalpathi Subramanian
Date
6/29/15, 5/18/17, 4/24/18
Parameters
<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
See also
Example tutorial at

http://bridgesuncc.github.io/Hello_World_Tutorials/Graph.html

Constructor & Destructor Documentation

Constructor

Member Function Documentation

void bridges.base.GraphAdjList< K, E1, E2 >.addEdge ( src,
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.

Parameters
src- source vertex of edge
dest- destination vertex of edge
void bridges.base.GraphAdjList< K, E1, E2 >.addEdge ( src,
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.

Parameters
src- source vertex of edge
dest- destination vertex of edge
weight- edge weight
void bridges.base.GraphAdjList< K, E1, E2 >.addVertex ( 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

Parameters
k- vertex id
E- vertex info, currently used as a label by default
Returns
none
HashMap<K, SLelement<Edge<K, E2> > > bridges.base.GraphAdjList< K, E1, E2 >.getAdjacencyList ( )

Gets the adjacency list (of type SLelement<Edge> )

Returns
- the graph's adjacency lists
SLelement<Edge<K, E2> > bridges.base.GraphAdjList< K, E1, E2 >.getAdjacencyList ( vertex)

Gets the adjacency list (of type SLelement<Edge <K> > of a vertex)

Parameters
-vertex key
Returns
- the graph's adjacency list corresponding to this vertex
String bridges.base.GraphAdjList< K, E1, E2 >.getDataStructType ( )

This method gets the data structure type

Returns
The date structure type as a string
String bridges.base.GraphAdjList< K, E1, E2 >.getDataStructureRepresentation ( )
E2 bridges.base.GraphAdjList< K, E1, E2 >.getEdgeData ( src,
dest 
)

Gets data for an edge

Parameters
src- source vertex of edge
dest- destination vertex of edge
LinkVisualizer bridges.base.GraphAdjList< K, E1, E2 >.getLinkVisualizer ( src,
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 ( 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 ( src)

Gets data for an edge

Parameters
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 ( 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 ( src,
dest,
E2  edge_data 
)

Sets data for an edge

Parameters
src- source vertex of edge
dest- destination vertex of edge
data- edge data
void bridges.base.GraphAdjList< K, E1, E2 >.setVertexData ( src,
E1  vertex_data 
)

Sets data for a graph vertex

Parameters
src- source vertex of edge
dest- destination vertex of edge
data- vertex data

The documentation for this class was generated from the following file: