org.gephi.graph.api

## Interface Subgraph

• All Superinterfaces:
Graph
All Known Subinterfaces:
DirectedSubgraph, UndirectedSubgraph

```public interface Subgraph
extends Graph```
A subgraph is a subset of a graph based on a graph view.

A subgraph has the same or less elements compared to the graph it's based on. This interface inherits from Graph and all read operations behave in a similar fashion. For instance, calling getNodes will return only nodes in this subgraph. However, write operations such as addNode or removeNode are used to control which elements are part of the view.

• ### Method Summary

All Methods
Modifier and Type Method and Description
`boolean` `addAllEdges(Collection<? extends Edge> edges)`
Adds a collection of edges to this subgraph.
`boolean` `addAllNodes(Collection<? extends Node> nodes)`
Adds a collection of nodes to this subgraph.
`boolean` `addEdge(Edge edge)`
Adds an edge to this subgraph.
`boolean` `addNode(Node node)`
Adds a node to this subgraph.
`void` `fill()`
Fills the subgraph so all elements in the graph are in the subgraph.
`Graph` `getRootGraph()`
Return the root graph this subgraph is based on.
`GraphView` `getView()`
Gets the view associated with this subgraph.
`void` `intersection(Subgraph subGraph)`
Intersects the given subgraph with this sugbgraph.
`void` `not()`
Inverse this subgraph so all elements in the graph are removed and all elements not in the graph are added.
`boolean` `removeAllEdges(Collection<? extends Edge> edges)`
Removes a collection of edges from this subgraph.
`boolean` `removeAllNodes(Collection<? extends Node> nodes)`
Removes a collection of nodes from this subgraph.
`boolean` `removeEdge(Edge edge)`
Removes an edge from this subgraph.
`boolean` `removeNode(Node node)`
Removes a node from this subgraph.
`void` `union(Subgraph subGraph)`
Unions the given subgraph with this sugbgraph.
• ### Methods inherited from interface org.gephi.graph.api.Graph

`clear, clearEdges, clearEdges, clearEdges, contains, contains, getAttribute, getAttribute, getAttribute, getAttributeKeys, getDegree, getEdge, getEdge, getEdge, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdges, getEdges, getEdges, getModel, getNeighbors, getNeighbors, getNode, getNodeCount, getNodes, getOpposite, getSelfLoops, hasEdge, hasNode, isAdjacent, isAdjacent, isDirected, isDirected, isIncident, isIncident, isMixed, isSelfLoop, isUndirected, readLock, readUnlock, readUnlockAll, removeAttribute, removeAttribute, removeAttribute, setAttribute, setAttribute, setAttribute, writeLock, writeUnlock`
• ### Method Detail

• #### getView

`GraphView getView()`
Gets the view associated with this subgraph.
Specified by:
`getView` in interface `Graph`
Returns:
the graph view
• #### getRootGraph

`Graph getRootGraph()`
Return the root graph this subgraph is based on.
Returns:
the root graph

`boolean addNode(Node node)`
Adds a node to this subgraph.

The node should be part of the root graph.

Specified by:
`addNode` in interface `Graph`
Parameters:
`node` - the node to add
Returns:
true if the node has been added, false otherwise

`boolean addAllNodes(Collection<? extends Node> nodes)`
Adds a collection of nodes to this subgraph.

The nodes should be part of the root graph.

Specified by:
`addAllNodes` in interface `Graph`
Parameters:
`nodes` - the nodes to add
Returns:
true if at least a node has been added, false otherwise

`boolean addEdge(Edge edge)`
Adds an edge to this subgraph.

The edge should be part of the root graph.

Specified by:
`addEdge` in interface `Graph`
Parameters:
`edge` - the edge to add
Returns:
true if the edge has been added, false otherwise

`boolean addAllEdges(Collection<? extends Edge> edges)`
Adds a collection of edges to this subgraph.

The edges should be part of the root graph.

Specified by:
`addAllEdges` in interface `Graph`
Parameters:
`edges` - the edges to add
Returns:
true if at least an edge has been added, false otherwise
• #### removeNode

`boolean removeNode(Node node)`
Removes a node from this subgraph.

The node should be part of the root graph.

Specified by:
`removeNode` in interface `Graph`
Parameters:
`node` - the node to remove
Returns:
true if removed, false otherwise
• #### removeAllNodes

`boolean removeAllNodes(Collection<? extends Node> nodes)`
Removes a collection of nodes from this subgraph.

The nodes should be part of the root graph.

Specified by:
`removeAllNodes` in interface `Graph`
Parameters:
`nodes` - the nodes to remove
Returns:
true if at least a node is removed, false otherwise
• #### removeEdge

`boolean removeEdge(Edge edge)`
Removes an edge from this subgraph.

The edge should be part of the root graph.

Specified by:
`removeEdge` in interface `Graph`
Parameters:
`edge` - the edge to remove
Returns:
true if removed, false otherwise
• #### removeAllEdges

`boolean removeAllEdges(Collection<? extends Edge> edges)`
Removes a collection of edges from this subgraph.

The edges should be part of the root graph.

Specified by:
`removeAllEdges` in interface `Graph`
Parameters:
`edges` - the edges to remove
Returns:
true if at least an edge has been removed, false otherwise
• #### fill

`void fill()`
Fills the subgraph so all elements in the graph are in the subgraph.
• #### union

`void union(Subgraph subGraph)`
Unions the given subgraph with this sugbgraph.

The given subgraph remains unchanged.

Parameters:
`subGraph` - the subgraph to do the union with
• #### intersection

`void intersection(Subgraph subGraph)`
Intersects the given subgraph with this sugbgraph.

The given subgraph remains unchanged.

Parameters:
`subGraph` - the subgraph to do the intersection with
• #### not

`void not()`
Inverse this subgraph so all elements in the graph are removed and all elements not in the graph are added.