infovis
Interface Graph

All Superinterfaces:
Constants, Metadata
All Known Implementing Classes:
AbstractGraphLayout, BasicSpringLayout, CircularLayout, DefaultGraph, DenseGraph, FRLayout, GraphProxy, GraphVisualization, GraphVizLayout, HierarchicalGraph, MatrixAxisVisualization, MatrixVisualization, MinimizerPolyLog, NodeLinkGraphVisualization, RandomGraphLayout, SpringLayout, TreeAsGraph

public interface Graph
extends Metadata

A Graph in an interface for a table of vertices and a table of edges, along with a set of methods to manage these tables as a graph.

Graph manage vertices and edges. Contrary to other graph packages, InfoVis does not implement a Vertex and Edge class. A vertex is simply an index in the table of vertices and an edge is an index in the table of edges. Apart from that rather unusual lack of object-orientedness, the provided interface is very similar to other graph packages. Simply, each time you think of the pseudo type Vertex or Edge, replace it by int. For example:

 int vertex1 = graph.addVertex();
 int vertex2 = graph.addVertex();
 int edge1 = graph.addEdge(vertex1, vertex2);
 

Any number of attrbutes can be added to vertices and edges, simply by adding columns to the vertex table and edge table:

  // Create a name for vertices
 StringColumn name = new StringColumn("name");
 graph.getVertexTable().addColumn(name);
 
 // Create a length for edges
 IntColumn length = new IntColumn("length");
 graph.getEdgeTable().addColumn(length);

 // Create 10 vertices linked together
 // and named vertex0, vertex1, ... 
 int prev = graph.addVertex(); 
 name.setExtend(v, "vertex0");
 for (int i = 1; i < 10; i++) {
     int v = graph.addVertex();
     name.setExtend(v, "vertex"+i);
     // Edge with previous vertex
     int e = graph.addEdge(prev, v);
     // Associate it a length of i
     length.setExtend(e, i);
     prev = v;
 }
 

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

Field Summary
static String GRAPH_TYPE
          Metadata key for the graph type.
static String GRAPH_TYPE_DIRECTED
          Metadata value for a directed graph.
static String GRAPH_TYPE_UNDIRECTED
          Metadata value for an undirected graph.
static int NIL
          NIL value for a vertex or edge.
 
Fields inherited from interface infovis.metadata.Constants
CONTRIBUTOR, COVERAGE, CREATOR, DATE, DESCRITION, FORMAT, IDENTIFIER, LANGUAGE, PUBLISHER, RELATION, RIGHTS, SOURCE, SUBJECT, TITLE, TYPE
 
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 "in" 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.
 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 first vertex of the specified edge.
 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.
 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 outgoing edges of 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 second 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 outgoing 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.
 RowIterator vertexIterator()
          Returns an iterator over the vertices of the graph.
 
Methods inherited from interface infovis.Metadata
getClientProperty, getMetadata
 

Field Detail

GRAPH_TYPE

static final String GRAPH_TYPE
Metadata key for the graph type.

See Also:
Constant Field Values

GRAPH_TYPE_DIRECTED

static final String GRAPH_TYPE_DIRECTED
Metadata value for a directed graph.

See Also:
Constant Field Values

GRAPH_TYPE_UNDIRECTED

static final String GRAPH_TYPE_UNDIRECTED
Metadata value for an undirected graph.

See Also:
Constant Field Values

NIL

static final int NIL
NIL value for a vertex or edge.

See Also:
Constant Field Values
Method Detail

getName

String getName()
Returns the Graph name.

Returns:
the Graph name.

setName

void setName(String name)
Sets the Graph name.

Parameters:
name - The Graph name to set

clear

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


isDirected

boolean isDirected()
Returns true if the graph is directed.

Returns:
true if the graph is directed.

setDirected

void setDirected(boolean directed)
Sets the graph to directed or undirected.

Parameters:
directed - boolean specifying whether the graph is directed or not.

getVerticesCount

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

Returns:
The number of vertices in the graph.

addVertex

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

Returns:
the "in" vertex number.

removeVertex

void removeVertex(int vertex)
Removes the specified vertex from the graph.

Parameters:
vertex - the vertex to remove

getEdgesCount

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

Returns:
the number of edges in the graph.

addEdge

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

Parameters:
v1 - the first vertex.
v2 - the second vertex.
Returns:
the new edge index.

removeEdge

void removeEdge(int edge)
Removes the specified edge.

Parameters:
edge - the edge to remove

getFirstVertex

int getFirstVertex(int edge)
Returns the first vertex of the specified edge. When the graph is directed, this is the source vertex.

Parameters:
edge - the edge.
Returns:
the first vertex of an edge or NIL.

getOtherVertex

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. If the specified vertex is the first vertex, it returns the second and vice versa.

Parameters:
edge - the edge
vertex - the vertex
Returns:
the other vertex or NIL if the vertex is not on any side of the edge.

getSecondVertex

int getSecondVertex(int edge)
Returns the second vertex of an edge. When the graph is directed, this is the destination/target vertex.

Parameters:
edge - the edge.
Returns:
the second vertex of the edge.

getOutEdgeAt

int getOutEdgeAt(int vertex,
                 int index)
Returns the outgoing edge of a specified vertex at a specified index.

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

int getInEdgeAt(int vertex,
                int index)
Returns the incoming edge of a specified vertrex at a specified index.

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.

getEdge

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

Parameters:
v1 - the first vertex.
v2 - the second vertex.
Returns:
an edge between two specified vertices or NIL if none exists.

findEdge

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

Parameters:
v1 - the first vertex.
v2 - the second vertex.
Returns:
an edge between two specified vertices creating one if none exists.

getOutDegree

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

Parameters:
vertex - the vertex.
Returns:
The out degree of the vertex.

outEdgeIterator

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

Parameters:
vertex - the vertex.
Returns:
the iterator over the outgoing edges of the vertex.

getInDegree

int getInDegree(int vertex)
Returns the in degree of the vertex, which is simply the number of incoming edges at the vertex.

Parameters:
vertex - the vertex.
Returns:
The number of incoming edges at this vertex.

inEdgeIterator

RowIterator inEdgeIterator(int vertex)
Returns an iterator over the incoming edges of specified vertex.

Parameters:
vertex - the vertex
Returns:
an iterator over the incoming edges of the specified vertex

getDegree

int getDegree(int vertex)
Returns the degree of the vertex, which is inDegree + outDegree.

Parameters:
vertex - the vertex.
Returns:
The degree of the vertex.

edgeIterator

RowIterator edgeIterator(int vertex)
Returns an iterator over all the edges (incoming and outgoing) of a specified vertex.

Parameters:
vertex - the vertex.
Returns:
the iterator over all the edges of the vertex.

vertexIterator

RowIterator vertexIterator()
Returns an iterator over the vertices of the graph.

Returns:
an iterator over the vertices of the graph

edgeIterator

RowIterator edgeIterator()
Returns an iterator over the edges of the graph.

Returns:
an iterator over the edges of the graph

getEdgeTable

DynamicTable getEdgeTable()
Returns the edgeTable.

Returns:
DefaultTable

getVertexTable

DynamicTable getVertexTable()
Returns the vertex Table.

Returns:
the vertex Table

addGraphChangedListener

void addGraphChangedListener(GraphChangedListener l)
Attaches a GraphChangedListener to the graph.

Parameters:
l - the GraphChangedListener to notify when the graph structure changes.

removeGraphChangedListener

void removeGraphChangedListener(GraphChangedListener l)
Removes a GraphChangedListener from the graph.

Parameters:
l - the GraphChangedListener to remove


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