Package org.gephi.graph.api
Interface Graph
-
- All Known Subinterfaces:
DirectedGraph,DirectedSubgraph,Subgraph,UndirectedGraph,UndirectedSubgraph
public interface GraphGraph interface.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaddAllEdges(Collection<? extends Edge> edges)Adds all edges in the collection to this graph.booleanaddAllNodes(Collection<? extends Node> nodes)Adds all nodes in the collection to this graph.booleanaddEdge(Edge edge)Adds an edge to this graph.booleanaddNode(Node node)Adds a node to this graph.voidclear()Clears all edges and all nodes in the graphvoidclearEdges()Clears all edges in the graphvoidclearEdges(Node node)Clears the edges incident to the given node.voidclearEdges(Node node, int type)Clears the edges of the given type incident to the given node.booleancontains(Edge edge)Returns true if edge is contained in this graph.booleancontains(Node node)Returns true if node is contained in this graph.ObjectgetAttribute(String key)Gets the attribute value for the given key.ObjectgetAttribute(String key, double timestamp)Gets the attribute for the given key and timestampObjectgetAttribute(String key, Interval interval)Gets the attribute for the given key and intervalSet<String>getAttributeKeys()Gets all attribute keys.intgetDegree(Node node)Gets the node degree.EdgegetEdge(Object id)Gets an edge by its identifier.EdgegetEdge(Node node1, Node node2)Gets the edge adjacent to node1 and node2.EdgegetEdge(Node node1, Node node2, int type)Gets the edge adjacent to node1 and node2 and from the given type.intgetEdgeCount()Gets the number of edges in the graph.intgetEdgeCount(int type)Gets the number of edges of the given type in the graph.EdgeIterablegetEdges()Gets all the edges in the graph.EdgeIterablegetEdges(int type)Gets all the edges of a particular type in the graph.EdgeIterablegetEdges(Node node)Gets all edges incident to a given node.EdgeIterablegetEdges(Node node, int type)Gets all edges incident to a given node with the given edge type.EdgeIterablegetEdges(Node node1, Node node2)Get the edges adjacent to node1 and node2.EdgeIterablegetEdges(Node node1, Node node2, int type)Gets the edges adjacent to node1 and node 2 and from the given type.GraphLockgetLock()Returns the graph lock, in case locking is enabled.GraphModelgetModel()Returns the model this graph belongs to.NodeIterablegetNeighbors(Node node)Gets all neighbors of a given node.NodeIterablegetNeighbors(Node node, int type)Gets all neighbors of a given node connected through the given edge type.NodegetNode(Object id)Gets a node given its identifier.intgetNodeCount()Gets the number of nodes in the graph.NodeIterablegetNodes()Gets all the nodes in the graph.NodegetOpposite(Node node, Edge edge)Gets the node at the opposite end of the given edge.EdgeIterablegetSelfLoops()Gets all the self-loop edges in the graph.intgetVersion()Returns a version number for this graph.GraphViewgetView()Gets the graph view associated to this graph.booleanhasEdge(Object id)Returns true if an edge with id as identifier exists.booleanhasNode(Object id)Returns true if a node with id as identifier exists.booleanisAdjacent(Node node1, Node node2)Returns true if node1 and node2 are adjacent.booleanisAdjacent(Node node1, Node node2, int type)Returns true if node1 and node2 are adjacent with an edge of the given type.booleanisDirected()Returns true if this graph is directed.booleanisDirected(Edge edge)Returns true if the given edge is directed.booleanisIncident(Edge edge1, Edge edge2)Returns true if edge1 and edge2 are incident.booleanisIncident(Node node, Edge edge)Returns true if the node and the edge are incident.booleanisMixed()Returns true if this graph is mixed (both directed and undirected edges).booleanisSelfLoop(Edge edge)Returns true if the given edge is a self-loop.booleanisUndirected()Returns true if this graph is undirected.voidreadLock()Opens a read lock for the current thread.voidreadUnlock()Closes a read lock for the current thread.voidreadUnlockAll()Closes all read locks for the current thread.booleanremoveAllEdges(Collection<? extends Edge> edges)Removes all edges in the collection from this graph.booleanremoveAllNodes(Collection<? extends Node> nodes)Removes all nodes in the collection from this graph.voidremoveAttribute(String key)Removes the attribute for the given key.voidremoveAttribute(String key, double timestamp)Removes the attribute for the given key and timestamp.voidremoveAttribute(String key, Interval interval)Removes the attribute for the given key and interval.booleanremoveEdge(Edge edge)Removes an edge from this graph.booleanremoveNode(Node node)Removes a node from this graph.booleanretainEdges(Collection<? extends Edge> edges)Retains only edges in this graph that are contained in the specified collection.booleanretainNodes(Collection<? extends Node> nodes)Retains only nodes in this graph that are contained in the specified collection.voidsetAttribute(String key, Object value)Sets the attribute value for the given key.voidsetAttribute(String key, Object value, double timestamp)Sets the attribute value for the given key and timestamp.voidsetAttribute(String key, Object value, Interval interval)Sets the attribute value for the given key and interval.voidwriteLock()Opens a write lock for the current thread.voidwriteUnlock()Closes a write lock for the current thread.
-
-
-
Method Detail
-
addEdge
boolean addEdge(Edge edge)
Adds an edge to this graph.- Parameters:
edge- the edge to add- Returns:
- true if the edge has been added, false if it already exists
-
addNode
boolean addNode(Node node)
Adds a node to this graph.- Parameters:
node- the node to add- Returns:
- true if the node has been added, false if it already exists
-
addAllEdges
boolean addAllEdges(Collection<? extends Edge> edges)
Adds all edges in the collection to this graph.- Parameters:
edges- the edge collection- Returns:
- true if at least one edge has been added, false otherwise
-
addAllNodes
boolean addAllNodes(Collection<? extends Node> nodes)
Adds all nodes in the collection to this graph.- Parameters:
nodes- the node collection- Returns:
- true if at least one node has been added, false otherwise
-
removeEdge
boolean removeEdge(Edge edge)
Removes an edge from this graph.- Parameters:
edge- the edge to remove- Returns:
- true if the edge was removed, false if it didn't exist
-
removeNode
boolean removeNode(Node node)
Removes a node from this graph.All edges attached to the node will be removed as well.
- Parameters:
node- the node to remove- Returns:
- true if the node was removed, false if it didn't exist
-
removeAllEdges
boolean removeAllEdges(Collection<? extends Edge> edges)
Removes all edges in the collection from this graph.- Parameters:
edges- the edge collection- Returns:
- true if at least one edge has been removed, false otherwise
-
removeAllNodes
boolean removeAllNodes(Collection<? extends Node> nodes)
Removes all nodes in the collection from this graph.- Parameters:
nodes- the node collection- Returns:
- true if at least one node has been removed, false otherwise
-
retainNodes
boolean retainNodes(Collection<? extends Node> nodes)
Retains only nodes in this graph that are contained in the specified collection.- Parameters:
nodes- the node collection- Returns:
- true if at least one node has been removed, false otherwise
-
retainEdges
boolean retainEdges(Collection<? extends Edge> edges)
Retains only edges in this graph that are contained in the specified collection.- Parameters:
edges- the edge collection- Returns:
- true if at least one edge has been removed, false otherwise
-
contains
boolean contains(Node node)
Returns true if node is contained in this graph.- Parameters:
node- the node to test- Returns:
- true if this graph contains node, false otherwise
-
contains
boolean contains(Edge edge)
Returns true if edge is contained in this graph.- Parameters:
edge- the edge to test- Returns:
- true if this graph contains edge, false otherwise
-
getNode
Node getNode(Object id)
Gets a node given its identifier.- Parameters:
id- the node id- Returns:
- the node, or null if not found
-
hasNode
boolean hasNode(Object id)
Returns true if a node with id as identifier exists.- Parameters:
id- node id- Returns:
- true if a node exists, false otherwise
-
getEdge
Edge getEdge(Object id)
Gets an edge by its identifier.- Parameters:
id- the edge id- Returns:
- the edge, or null if not found
-
hasEdge
boolean hasEdge(Object id)
Returns true if an edge with id as identifier exists.- Parameters:
id- edge id- Returns:
- true if an edge exists, false otherwise
-
getEdge
Edge getEdge(Node node1, Node node2)
Gets the edge adjacent to node1 and node2.If multiple parallel edges exist it returns the first edge.
- Parameters:
node1- first nodenode2- second node- Returns:
- adjacent edge, or null if not found
-
getEdges
EdgeIterable getEdges(Node node1, Node node2)
Get the edges adjacent to node1 and node2.If there aren't any parallel edges only one edge will be returned.
- Parameters:
node1- first nodenode2- second node- Returns:
- adjacent edges
-
getEdge
Edge getEdge(Node node1, Node node2, int type)
Gets the edge adjacent to node1 and node2 and from the given type.If multiple parallel edges exist it returns the first edge.
- Parameters:
node1- the first nodenode2- the second nodetype- the edge type- Returns:
- the adjacent edge, or null if not found
-
getEdges
EdgeIterable getEdges(Node node1, Node node2, int type)
Gets the edges adjacent to node1 and node 2 and from the given type.If there aren't any parallel edges only one edge will be returned.
- Parameters:
node1- the first nodenode2- the second nodetype- the edge type- Returns:
- the adjacent edges, or an empty iterator if not found
-
getNodes
NodeIterable getNodes()
Gets all the nodes in the graph.- Returns:
- a node iterable over all nodes
-
getEdges
EdgeIterable getEdges()
Gets all the edges in the graph.- Returns:
- an edge iterable over all edges
-
getEdges
EdgeIterable getEdges(int type)
Gets all the edges of a particular type in the graph.- Parameters:
type- edge type- Returns:
- an edge iterable over all edges of this type
-
getSelfLoops
EdgeIterable getSelfLoops()
Gets all the self-loop edges in the graph.- Returns:
- an edge iterable over all self-loops
-
getNeighbors
NodeIterable getNeighbors(Node node)
Gets all neighbors of a given node.- Parameters:
node- the node to get neighbors- Returns:
- a node iterable over the neighbors
-
getNeighbors
NodeIterable getNeighbors(Node node, int type)
Gets all neighbors of a given node connected through the given edge type.- Parameters:
node- the node to get neighborstype- the edge type- Returns:
- a node iterable over the neigbors
-
getEdges
EdgeIterable getEdges(Node node)
Gets all edges incident to a given node.- Parameters:
node- the node to get edges from- Returns:
- an edge iterable of all edges connected to the node
-
getEdges
EdgeIterable getEdges(Node node, int type)
Gets all edges incident to a given node with the given edge type.- Parameters:
node- the node to get edges fromtype- the edge type- Returns:
- an edge iterable of the edges connected to the node
-
getNodeCount
int getNodeCount()
Gets the number of nodes in the graph.- Returns:
- the node count
-
getEdgeCount
int getEdgeCount()
Gets the number of edges in the graph.- Returns:
- the edge count
-
getEdgeCount
int getEdgeCount(int type)
Gets the number of edges of the given type in the graph.- Parameters:
type- the edge type- Returns:
- the edge count for the given type
-
getOpposite
Node getOpposite(Node node, Edge edge)
Gets the node at the opposite end of the given edge.- Parameters:
node- the node to get the oppositeedge- the edge connected to both nodes- Returns:
- the opposite node
-
getDegree
int getDegree(Node node)
Gets the node degree.- Parameters:
node- the node- Returns:
- the degree
-
isSelfLoop
boolean isSelfLoop(Edge edge)
Returns true if the given edge is a self-loop.- Parameters:
edge- the edge to test- Returns:
- true if self-loop, false otherwise
-
isDirected
boolean isDirected(Edge edge)
Returns true if the given edge is directed.- Parameters:
edge- the edge to test- Returns:
- true if directed, false otherwise
-
isAdjacent
boolean isAdjacent(Node node1, Node node2)
Returns true if node1 and node2 are adjacent.- Parameters:
node1- the first nodenode2- the second node- Returns:
- true if node1 is adjacent to node2, false otherwise
-
isAdjacent
boolean isAdjacent(Node node1, Node node2, int type)
Returns true if node1 and node2 are adjacent with an edge of the given type.- Parameters:
node1- the first nodenode2- the second nodetype- the edge type- Returns:
- true if node1 and node2 are adjacent with an edge og the given type, false otherwise
-
isIncident
boolean isIncident(Edge edge1, Edge edge2)
Returns true if edge1 and edge2 are incident.- Parameters:
edge1- the first edgeedge2- the second edge- Returns:
- true if edge1 is incident to edge2, false otherwise
-
isIncident
boolean isIncident(Node node, Edge edge)
Returns true if the node and the edge are incident.- Parameters:
node- the nodeedge- the edge- Returns:
- true if the node and edge are incident, false otherwise
-
clearEdges
void clearEdges(Node node)
Clears the edges incident to the given node.- Parameters:
node- the node to clear edges from
-
clearEdges
void clearEdges(Node node, int type)
Clears the edges of the given type incident to the given node.- Parameters:
node- the node to clear edges fromtype- the edge type
-
clear
void clear()
Clears all edges and all nodes in the graph
-
clearEdges
void clearEdges()
Clears all edges in the graph
-
getView
GraphView getView()
Gets the graph view associated to this graph.- Returns:
- the graph view
-
getAttribute
Object getAttribute(String key)
Gets the attribute value for the given key.- Parameters:
key- the key- Returns:
- the attribute value, or null if not found
-
getAttribute
Object getAttribute(String key, double timestamp)
Gets the attribute for the given key and timestamp- Parameters:
key- the keytimestamp- the timestamp- Returns:
- the attribute value, or null if not found
-
getAttribute
Object getAttribute(String key, Interval interval)
Gets the attribute for the given key and interval- Parameters:
key- the keyinterval- the interval- Returns:
- the attribute value, or null if not found
-
setAttribute
void setAttribute(String key, Object value)
Sets the attribute value for the given key.- Parameters:
key- the keyvalue- the value
-
removeAttribute
void removeAttribute(String key)
Removes the attribute for the given key.- Parameters:
key- key
-
setAttribute
void setAttribute(String key, Object value, double timestamp)
Sets the attribute value for the given key and timestamp.- Parameters:
key- the keyvalue- the valuetimestamp- the timestamp
-
setAttribute
void setAttribute(String key, Object value, Interval interval)
Sets the attribute value for the given key and interval.- Parameters:
key- the keyvalue- the valueinterval- the interval
-
removeAttribute
void removeAttribute(String key, double timestamp)
Removes the attribute for the given key and timestamp.- Parameters:
key- keytimestamp- timestamp
-
removeAttribute
void removeAttribute(String key, Interval interval)
Removes the attribute for the given key and interval.- Parameters:
key- keyinterval- interval
-
getAttributeKeys
Set<String> getAttributeKeys()
Gets all attribute keys.- Returns:
- a set of all attribute keys
-
getModel
GraphModel getModel()
Returns the model this graph belongs to.- Returns:
- graph model
-
getVersion
int getVersion()
Returns a version number for this graph.The version gets altered when the graph structure changes.
- Returns:
- graph version
- See Also:
for a more sophisticated way to track changes
-
isDirected
boolean isDirected()
Returns true if this graph is directed.- Returns:
- true if directed, false otherwise
-
isUndirected
boolean isUndirected()
Returns true if this graph is undirected.- Returns:
- true if undirected, false otherwise
-
isMixed
boolean isMixed()
Returns true if this graph is mixed (both directed and undirected edges).- Returns:
- true if mixed, false otherwise
-
readLock
void readLock()
Opens a read lock for the current thread.
-
readUnlock
void readUnlock()
Closes a read lock for the current thread.
-
readUnlockAll
void readUnlockAll()
Closes all read locks for the current thread.
-
writeLock
void writeLock()
Opens a write lock for the current thread.
-
writeUnlock
void writeUnlock()
Closes a write lock for the current thread.
-
getLock
GraphLock getLock()
Returns the graph lock, in case locking is enabled. The graph lock controls the multi-thread access to the graph structure.- Returns:
- graph lock
-
-