infovis.graph
Class DefaultGraph

java.lang.Object
  extended by infovis.graph.DefaultGraph
All Implemented Interfaces:
Graph, Metadata, Constants, EventListener, TableModelListener
Direct Known Subclasses:
HierarchicalGraph

public class DefaultGraph
extends Object
implements Graph, TableModelListener

Version:
$Revision: 1.32 $
Author:
Jean-Daniel Fekete

Field Summary
static String FIRSTEDGE_COLUMN
          Name of the column containing the index of the first outgoing edge.
static String FIRSTINEDGE_COLUMN
          Name of the column containing the first incoming edge.
static String GRAPH_METADATA
          The Metadata key of the Graph using the Table
static String INVERTEX_COLUMN
          Name of the column containing the first vertex in the edge table.
static String LASTEDGE_COLUMN
          Name of the column containing the index of the last outgoing edge.
static String LASTINEDGE_COLUMN
          Name of the column containing last incoming edge.
static String NEXTEDGE_COLUMN
          Name of the column containing the next ougoing edge in the edge table.
static String NEXTINEDGE_COLUMN
          Name of the column containing the next incoming edge in the edge table.
static String OUTVERTEX_COLUMN
          Name of the column containing the second vertex in the edge table.
static String PREVEDGE_COLUMN
          Name of the column containing the previous outgoing edge in the edge table.
static String PREVINEDGE_COLUMN
          Name of the column containing the previous incoming edge in the edge table.
 
Fields inherited from interface infovis.Graph
GRAPH_TYPE, GRAPH_TYPE_DIRECTED, GRAPH_TYPE_UNDIRECTED, NIL
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
Constructor Summary
DefaultGraph()
          Constructor for Graph.
 
Method Summary
 int addEdge(int v1, int v2)
          Adds a new edge between two vertices.
 void addGraphChangedListener(GraphChangedListener l)
          Attaches a GraphChangedListener to the graph.
 int addVertex()
          Adds a new vertex to the graph.
 void clear()
          Clears the Graph.
 RowIterator edgeIterator()
          Returns an iterator over the edges of the graph.
 RowIterator edgeIterator(int vertex)
          Returns an iterator over all the edges (incoming and outgoing) of a specified vertex.
 int findEdge(int v1, int v2)
          Returns an edge between two specified vertices.
 MutableAttributeSet getClientProperty()
          Returns the clientPropery.
 int getDegree(int vertex)
          Returns the degree of the vertex, which is inDegree + outDegree.
 int getEdge(int v1, int v2)
          Returns an edge between two specified vertices.
 int getEdgesCount()
          Returns the number of edges in the graph.
 DynamicTable getEdgeTable()
          Returns the edgeTable.
 int getFirstVertex(int edge)
          Returns the "in" vertex of an edge.
static Graph getGraph(Table table)
           
 int getInDegree(int vertex)
          Returns the in degree of the vertex, which is simply the number of incoming edges at the vertex.
 int getInEdgeAt(int vertex, int index)
          Returns the incoming edge of a specified vertrex at a specified index.
 MutableAttributeSet getMetadata()
          Returns the metadata.
 String getName()
          Returns the Graph name.
 int getOtherVertex(int edge, int vertex)
          Given a specified edge and a vertex on one side of this edge, returns the vertex on the other side.
 int getOutDegree(int vertex)
          Returns the out degree of the vertex, which is simply the number of edges starting from the vertex.
 int getOutEdgeAt(int vertex, int index)
          Returns the outgoing edge of a specified vertex at a specified index.
 int getSecondVertex(int edge)
          Returns the "out" vertex of an edge.
 DynamicTable getVertexTable()
          Returns the vertex Table.
 int getVerticesCount()
          Returns the number of vertices in the graph
 RowIterator inEdgeIterator(int vertex)
          Returns an iterator over the incoming edges of specified vertex.
 boolean isDirected()
          Returns true if the graph is directed.
 RowIterator outEdgeIterator(int vertex)
          Returns an iterator over the edges of a specified vertex.
 void removeEdge(int edge)
          Removes the specified edge.
 void removeGraphChangedListener(GraphChangedListener l)
          Removes a GraphChangedListener from the graph.
 void removeVertex(int vertex)
          Removes the specified vertex from the graph.
 void setDirected(boolean directed)
          Sets the graph to directed or undirected.
 void setName(String name)
          Sets the Graph name.
 void tableChanged(TableModelEvent e)
           
 RowIterator vertexIterator()
          Returns an iterator over the vertices of the graph.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FIRSTEDGE_COLUMN

public static final String FIRSTEDGE_COLUMN
Name of the column containing the index of the first outgoing edge.

See Also:
Constant Field Values

LASTEDGE_COLUMN

public static final String LASTEDGE_COLUMN
Name of the column containing the index of the last outgoing edge.

See Also:
Constant Field Values

INVERTEX_COLUMN

public static final String INVERTEX_COLUMN
Name of the column containing the first vertex in the edge table.

See Also:
Constant Field Values

OUTVERTEX_COLUMN

public static final String OUTVERTEX_COLUMN
Name of the column containing the second vertex in the edge table.

See Also:
Constant Field Values

NEXTEDGE_COLUMN

public static final String NEXTEDGE_COLUMN
Name of the column containing the next ougoing edge in the edge table.

See Also:
Constant Field Values

PREVEDGE_COLUMN

public static final String PREVEDGE_COLUMN
Name of the column containing the previous outgoing edge in the edge table.

See Also:
Constant Field Values

GRAPH_METADATA

public static final String GRAPH_METADATA
The Metadata key of the Graph using the Table

See Also:
Constant Field Values

FIRSTINEDGE_COLUMN

public static final String FIRSTINEDGE_COLUMN
Name of the column containing the first incoming edge.

See Also:
Constant Field Values

LASTINEDGE_COLUMN

public static final String LASTINEDGE_COLUMN
Name of the column containing last incoming edge.

See Also:
Constant Field Values

NEXTINEDGE_COLUMN

public static final String NEXTINEDGE_COLUMN
Name of the column containing the next incoming edge in the edge table.

See Also:
Constant Field Values

PREVINEDGE_COLUMN

public static final String PREVINEDGE_COLUMN
Name of the column containing the previous incoming edge in the edge table.

See Also:
Constant Field Values
Constructor Detail

DefaultGraph

public DefaultGraph()
Constructor for Graph.

Method Detail

getGraph

public static Graph getGraph(Table table)

getClientProperty

public MutableAttributeSet getClientProperty()
Returns the clientPropery.

Specified by:
getClientProperty in interface Metadata
Returns:
Map the clientPropery map.

getMetadata

public MutableAttributeSet getMetadata()
Returns the metadata.

Specified by:
getMetadata in interface Metadata
Returns:
Map the metadata map.

getName

public String getName()
Description copied from interface: Graph
Returns the Graph name.

Specified by:
getName in interface Graph
Returns:
the Graph name.

setName

public void setName(String name)
Description copied from interface: Graph
Sets the Graph name.

Specified by:
setName in interface Graph
Parameters:
name - The Graph name to set

clear

public void clear()
Description copied from interface: Graph
Clears the Graph.

After this method, the graph tables are almost in the same state as if it had been created afresh except it contains the same columns as before but they are all cleared.

Specified by:
clear in interface Graph

isDirected

public boolean isDirected()
Description copied from interface: Graph
Returns true if the graph is directed.

Specified by:
isDirected in interface Graph
Returns:
true if the graph is directed.

setDirected

public void setDirected(boolean directed)
Description copied from interface: Graph
Sets the graph to directed or undirected.

Specified by:
setDirected in interface Graph
Parameters:
directed - boolean specifying whether the graph is directed or not.

getVerticesCount

public int getVerticesCount()
Returns the number of vertices in the graph

Specified by:
getVerticesCount in interface Graph
Returns:
The number of vertices in the graph.

addVertex

public int addVertex()
Adds a new vertex to the graph.

Specified by:
addVertex in interface Graph
Returns:
the vertex number.

removeVertex

public void removeVertex(int vertex)
Description copied from interface: Graph
Removes the specified vertex from the graph.

Specified by:
removeVertex in interface Graph
Parameters:
vertex - the vertex to remove

getEdgesCount

public int getEdgesCount()
Returns the number of edges in the graph.

Specified by:
getEdgesCount in interface Graph
Returns:
the number of edges in the graph.

addEdge

public int addEdge(int v1,
                   int v2)
Adds a new edge between two vertices.

Specified by:
addEdge in interface Graph
Parameters:
v1 - the first vertex.
v2 - the second vertex.
Returns:
the new edge index.

removeEdge

public void removeEdge(int edge)
Description copied from interface: Graph
Removes the specified edge.

Specified by:
removeEdge in interface Graph
Parameters:
edge - the edge to remove

getFirstVertex

public int getFirstVertex(int edge)
Returns the "in" vertex of an edge.

Specified by:
getFirstVertex in interface Graph
Parameters:
edge - the edge.
Returns:
the "in" vertex of an edge or NIL.

getSecondVertex

public int getSecondVertex(int edge)
Returns the "out" vertex of an edge.

Specified by:
getSecondVertex in interface Graph
Parameters:
edge - the edge.
Returns:
the "out" vertex of an edge.

getOutEdgeAt

public int getOutEdgeAt(int vertex,
                        int index)
Description copied from interface: Graph
Returns the outgoing edge of a specified vertex at a specified index.

Specified by:
getOutEdgeAt in interface Graph
Parameters:
vertex - the in vertex of the requested edge
index - the index of the edge in the edge list of the vertex
Returns:
the outgoing edge of a specified vertex at a specified index or NIL.

getInEdgeAt

public int getInEdgeAt(int vertex,
                       int index)
Description copied from interface: Graph
Returns the incoming edge of a specified vertrex at a specified index.

Specified by:
getInEdgeAt in interface Graph
Parameters:
vertex - the out vertex of the requested edge
index - the index of the edge in the edge list of the vertex
Returns:
the incoming edge of a specified vertex at a specified index or NIL.

getOtherVertex

public int getOtherVertex(int edge,
                          int vertex)
Description copied from interface: Graph
Given a specified edge and a vertex on one side of this edge, returns the vertex on the other side. If the specified vertex is the first vertex, it returns the second and vice versa.

Specified by:
getOtherVertex in interface Graph
Parameters:
edge - the edge
vertex - the vertex
Returns:
the other vertex or NIL if the vertex is not on any side of the edge.

getEdge

public int getEdge(int v1,
                   int v2)
Returns an edge between two specified vertices.

Specified by:
getEdge in interface Graph
Parameters:
v1 - the first vertex.
v2 - the second vertex.
Returns:
an edge between two specified vertices or NIL if none exists.

findEdge

public int findEdge(int v1,
                    int v2)
Returns an edge between two specified vertices.

Specified by:
findEdge in interface Graph
Parameters:
v1 - the first vertex.
v2 - the second vertex.
Returns:
an edge between two specified vertices creating one if none exists.

getOutDegree

public int getOutDegree(int vertex)
Returns the out degree of the vertex, which is simply the number of edges starting from the vertex.

Specified by:
getOutDegree in interface Graph
Parameters:
vertex - the vertex.
Returns:
The out degree of the vertex.

getInDegree

public int getInDegree(int vertex)
Description copied from interface: Graph
Returns the in degree of the vertex, which is simply the number of incoming edges at the vertex.

Specified by:
getInDegree in interface Graph
Parameters:
vertex - the vertex.
Returns:
The number of incoming edges at this vertex.

getDegree

public int getDegree(int vertex)
Description copied from interface: Graph
Returns the degree of the vertex, which is inDegree + outDegree.

Specified by:
getDegree in interface Graph
Parameters:
vertex - the vertex.
Returns:
The degree of the vertex.

edgeIterator

public RowIterator edgeIterator(int vertex)
Description copied from interface: Graph
Returns an iterator over all the edges (incoming and outgoing) of a specified vertex.

Specified by:
edgeIterator in interface Graph
Parameters:
vertex - the vertex.
Returns:
the iterator over all the edges of the vertex.

outEdgeIterator

public RowIterator outEdgeIterator(int vertex)
Returns an iterator over the edges of a specified vertex.

Specified by:
outEdgeIterator in interface Graph
Parameters:
vertex - the vertex.
Returns:
the iterator over the edges of the vertex.

inEdgeIterator

public RowIterator inEdgeIterator(int vertex)
Description copied from interface: Graph
Returns an iterator over the incoming edges of specified vertex.

Specified by:
inEdgeIterator in interface Graph
Parameters:
vertex - the vertex
Returns:
an iterator over the incoming edges of the specified vertex

vertexIterator

public RowIterator vertexIterator()
Description copied from interface: Graph
Returns an iterator over the vertices of the graph.

Specified by:
vertexIterator in interface Graph
Returns:
an iterator over the vertices of the graph

edgeIterator

public RowIterator edgeIterator()
Description copied from interface: Graph
Returns an iterator over the edges of the graph.

Specified by:
edgeIterator in interface Graph
Returns:
an iterator over the edges of the graph

getEdgeTable

public DynamicTable getEdgeTable()
Returns the edgeTable.

Specified by:
getEdgeTable in interface Graph
Returns:
DefaultTable

getVertexTable

public DynamicTable getVertexTable()
Description copied from interface: Graph
Returns the vertex Table.

Specified by:
getVertexTable in interface Graph
Returns:
the vertex Table

addGraphChangedListener

public void addGraphChangedListener(GraphChangedListener l)
Description copied from interface: Graph
Attaches a GraphChangedListener to the graph.

Specified by:
addGraphChangedListener in interface Graph
Parameters:
l - the GraphChangedListener to notify when the graph structure changes.

removeGraphChangedListener

public void removeGraphChangedListener(GraphChangedListener l)
Description copied from interface: Graph
Removes a GraphChangedListener from the graph.

Specified by:
removeGraphChangedListener in interface Graph
Parameters:
l - the GraphChangedListener to remove

tableChanged

public void tableChanged(TableModelEvent e)
Specified by:
tableChanged in interface TableModelListener


Copyright 2005 by Jean-Daniel Fekete and INRIA, France All rights reserved.