public interface GraphModel
GraphModel
is the entry point for this API and provide methods
to create, access and modify graphs. It supports the most common graph
paradigms and a complete support for graphs over time as well.
New instances can be obtained via the embedded factory:
GraphModel model = GraphModel.Factory.newInstance();This API revolves around a set of simple concepts. A
GraphModel
encapsulate all elements and metadata associated with
a graph structure. In other words its a single graph but it also contains
configuration, indices, views and other less important services such as
observers.
Then, GraphModel
gives access to the Graph
interface, which focuses only on the graph structure and provide methods to
add, remove, get and iterate nodes and edges.
The Graph
contains nodes and edges, which both implement the
Element
interface. This Element
interface gives
access to methods that manipulate the attributes associated to nodes and
edges.
Any number of attributes can be associated to elements but are managed
through the Table
and Column
interfaces. A
GraphModel
gives access by default to a node and edge table. A
Table
is simply a list of columns, which each has a unique
identifier and a type (e.g. integer). Attribute values can only be associated
with elements for existing columns.
Attributes are automatically indexed and information such as the number of
elements with a particular value can be obtained from the Index
interface.
Finally, this API supports the concept of graph views. A view is a mask on
the graph structure and represents a subgraph. The user controls the set of
nodes and edges in the view by obtaining a Subgraph
for a
specific GraphView
. Views can directly be created and destroyed
from this model.
Elements should be created through the factory()
method.
For performance reasons, edge labels are internally represented as integers
and the mapping between arbitrary labels is managed through the addEdgeType(java.lang.Object)
and getEdgeType(java.lang.Object)
methods. By default, edges have
a null
label, which is internally represented as zero.
Modifier and Type | Interface and Description |
---|---|
static class |
GraphModel.Factory
Utility to create new graph model instances.
|
static class |
GraphModel.Serialization
Serialization utility to read/write graph models from/to input/output.
|
Modifier and Type | Method and Description |
---|---|
int |
addEdgeType(Object label)
Adds a new edge type and returns the integer identifier.
|
GraphBridge |
bridge()
Returns the graph bridge.
|
GraphView |
copyView(GraphView view)
Creates a new graph view based on an existing view.
|
GraphView |
copyView(GraphView view,
boolean node,
boolean edge)
Creates a new graph based on an existing view.
|
GraphObserver |
createGraphObserver(Graph graph,
boolean withGraphDiff)
Creates and returns a new graph observer.
|
GraphView |
createView()
Creates a new graph view.
|
GraphView |
createView(boolean node,
boolean edge)
Creates a new graph view.
|
void |
destroyView(GraphView view)
Destroys the given view.
|
GraphFactory |
factory()
Returns the graph factory.
|
Configuration |
getConfiguration()
Returns the current configuration.
|
DirectedGraph |
getDirectedGraph()
Gets the full graph with the directed interface.
|
DirectedSubgraph |
getDirectedGraph(GraphView view)
Gets the directed graph for the given graph view.
|
DirectedGraph |
getDirectedGraphVisible()
Gets the visible graph with the directed interface.
|
Index<Edge> |
getEdgeIndex()
Gets the edge index.
|
Index<Edge> |
getEdgeIndex(GraphView view)
Gets the edge index for the given graph view.
|
Table |
getEdgeTable()
Returns the edge table.
|
TimeIndex<Edge> |
getEdgeTimeIndex()
Gets the edge time index.
|
TimeIndex<Edge> |
getEdgeTimeIndex(GraphView view)
Gets the edge time index for the given view.
|
int |
getEdgeType(Object label)
Gets the edge type for the given label.
|
int |
getEdgeTypeCount()
Returns the number of different edge types.
|
Object |
getEdgeTypeLabel(int id)
Gets the edge label associated with the given type.
|
Object[] |
getEdgeTypeLabels()
Returns the edge type labels.
|
int[] |
getEdgeTypes()
Returns the edge types.
|
Graph |
getGraph()
Gets the full graph.
|
Subgraph |
getGraph(GraphView view)
Gets the graph for the given graph view.
|
Graph |
getGraphVisible()
Get the visible graph.
|
int |
getMaxEdgeStoreId()
Returns the maximum store id number edges have in this model.
|
int |
getMaxNodeStoreId()
Returns the maximum store id number nodes have in this model.
|
Index<Node> |
getNodeIndex()
Gets the node index.
|
Index<Node> |
getNodeIndex(GraphView view)
Gets the node index for the given graph view.
|
Table |
getNodeTable()
Returns the node table.
|
TimeIndex<Node> |
getNodeTimeIndex()
Gets the node time index.
|
TimeIndex<Node> |
getNodeTimeIndex(GraphView view)
Gets the node time index for the given view.
|
Interval |
getTimeBounds()
Gets the time bounds.
|
Interval |
getTimeBounds(GraphView view)
Gets the time bounds for the given graph view.
|
Interval |
getTimeBoundsVisible()
Gets the time bounds for the visible graph.
|
TimeFormat |
getTimeFormat()
Returns the time format used to display time.
|
org.joda.time.DateTimeZone |
getTimeZone()
Returns the time zone used to display time.
|
UndirectedGraph |
getUndirectedGraph()
Gets the full graph with the undirected interface.
|
UndirectedSubgraph |
getUndirectedGraph(GraphView view)
Gets the undirected graph for the given graph view.
|
UndirectedGraph |
getUndirectedGraphVisible()
Gets the visible graph with the undirected interface.
|
GraphView |
getVisibleView()
Gets the visible view.
|
boolean |
isDirected()
Returns true if the graph is directed.
|
boolean |
isDynamic()
Returns true if the graph is dynamic.
|
boolean |
isMixed()
Returns true if the graph is mixed (both directed and undirected edges).
|
boolean |
isMultiGraph()
Returns true if the graph is multi-graph (multiple types of edges).
|
boolean |
isUndirected()
Returns true if the graph is undirected.
|
void |
setConfiguration(Configuration configuration)
Sets a new configuration for this graph model.
|
void |
setTimeFormat(TimeFormat timeFormat)
Sets the time format used to display time.
|
void |
setTimeInterval(GraphView view,
Interval interval)
Sets the given time interval to the view.
|
void |
setTimeZone(org.joda.time.DateTimeZone timeZone)
Sets the time zone used to display time.
|
void |
setVisibleView(GraphView view)
Sets the visible view.
|
GraphFactory factory()
GraphBridge bridge()
Graph getGraph()
Graph getGraphVisible()
The visible graph may be the full graph (default) or a graph view.
Subgraph getGraph(GraphView view)
view
- graph viewDirectedGraph getDirectedGraph()
DirectedGraph getDirectedGraphVisible()
UndirectedGraph getUndirectedGraph()
UndirectedGraph getUndirectedGraphVisible()
DirectedSubgraph getDirectedGraph(GraphView view)
view
- graph viewUndirectedSubgraph getUndirectedGraph(GraphView view)
view
- graph viewGraphView getVisibleView()
void setVisibleView(GraphView view)
If view is null, it restores the main view.
view
- viewint addEdgeType(Object label)
If the type already exists, it returns the existing identifier.
label
- edge type labelint getEdgeType(Object label)
label
- edge labelObject getEdgeTypeLabel(int id)
id
- edge typeint getEdgeTypeCount()
int[] getEdgeTypes()
Object[] getEdgeTypeLabels()
boolean isDirected()
boolean isUndirected()
boolean isMixed()
boolean isDynamic()
boolean isMultiGraph()
GraphView createView()
GraphView createView(boolean node, boolean edge)
The node and edge parameters allows to restrict the view filtering to only nodes or only edges. By default, the view applies to both nodes and edges.
node
- true to enable node view, false otherwiseedge
- true to enable edge view, false otherwiseGraphView copyView(GraphView view)
view
- view to copyGraphView copyView(GraphView view, boolean node, boolean edge)
The node and edge parameters allows to restrict the view filtering to only nodes or only edges. By default, the view applies to both nodes and edges.
view
- view to copynode
- true to enable node view, false otherwiseedge
- true to enable edge view, false otherwisevoid destroyView(GraphView view)
view
- view to destroyvoid setTimeInterval(GraphView view, Interval interval)
Each view can be configured with a time interval to filter a graph over time.
view
- the view to configureinterval
- the time intervalTable getNodeTable()
A GraphModel
always has node and edge
tables by default.
Table getEdgeTable()
A GraphModel
always has node and edge
tables by default.
Index<Node> getNodeIndex(GraphView view)
view
- the view to get the index fromIndex<Edge> getEdgeIndex(GraphView view)
view
- the view to get the index fromTimeIndex<Node> getNodeTimeIndex()
TimeIndex<Node> getNodeTimeIndex(GraphView view)
view
- the view to get the index fromTimeIndex<Edge> getEdgeTimeIndex()
TimeIndex<Edge> getEdgeTimeIndex(GraphView view)
view
- view to get the index fromInterval getTimeBounds()
The time bounds is an interval made of the minimum and maximum time observed in the entire graph.
Interval getTimeBoundsVisible()
The time bounds is an interval made of the minimum and maximum time observed in the entire graph.
Interval getTimeBounds(GraphView view)
The time bounds is an interval made of the minimum and maximum time observed in the entire graph.
view
- the graph viewGraphObserver createGraphObserver(Graph graph, boolean withGraphDiff)
graph
- the graph to observewithGraphDiff
- true to include graph difference feature, false
otherwiseTimeFormat getTimeFormat()
void setTimeFormat(TimeFormat timeFormat)
timeFormat
- time formatorg.joda.time.DateTimeZone getTimeZone()
void setTimeZone(org.joda.time.DateTimeZone timeZone)
timeZone
- time zoneConfiguration getConfiguration()
void setConfiguration(Configuration configuration)
Note that this method only works if the graph model is empty.
configuration
- new configurationIllegalStateException
- if the graph model isn't emptyint getMaxNodeStoreId()
Each node has a unique store identifier which can be retrieved from
Element.getStoreId()
. This maximum number can help design
algorithms thar rely on storing nodes in a array. Note that not all
consecutive ids may be assigned.
int getMaxEdgeStoreId()
Each edge has a unique store identifier which can be retrieved from
Element.getStoreId()
. This maximum number can help design
algorithms thar rely on storing edges in a array. Note that not all
consecutive ids may be assigned.
Copyright © 2007–2015 Gephi Consortium. All rights reserved.