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

The GraphAdjMatrix class can be used to represent adjacency matrix based graphs in BRIDGES. More...

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

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)
 
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 ()
 
- 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 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.

Author
Kalpathi Subramanian, Mihai Mehedint
Date
7/12/15, 5/18/17, 4/23/18
Parameters
<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
See also
Example tutorial at

?? TO DO

Constructor & Destructor Documentation

Constructor

Member Function Documentation

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

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

Parameters
src- source vertex of edge
dest- destination vertex of edge
weight- edge weight
void bridges.base.GraphAdjMatrix< 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 key value
3- user specified data, part of the vertex data
HashMap<K, HashMap<K, Integer> > bridges.base.GraphAdjMatrix< K, E1, E2 >.getAdjacencyMatrix ( )

Gets the adjacency matrix

Returns
- the graph's adjacency matrix
HashMap<K, Integer> bridges.base.GraphAdjMatrix< K, E1, E2 >.getAdjacencyMatrix ( key)

Gets the row of the adjacency matrix corresponding to the key

Parameters
keykey value
Returns
- the graph's adjacency matrix
String bridges.base.GraphAdjMatrix< K, E1, E2 >.getDataStructType ( )

This method gets the data structure type

Returns
The date structure type as a string
String bridges.base.GraphAdjMatrix< K, E1, E2 >.getDataStructureRepresentation ( )
E2 bridges.base.GraphAdjMatrix< 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.GraphAdjMatrix< 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

E1 bridges.base.GraphAdjMatrix< 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.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 ( 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 ( src,
dest,
E2  data 
)

Sets data for an edge

Parameters
src- source vertex of edge
dest- destination vertex of edge
data- edge data
void bridges.base.GraphAdjMatrix< 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: