Graph view define a
subgraph, i.e. a subset of the original graph.
GraphModel
has at least a single view, called the
main view, which contains 100% of the graph. Other views can be defined by users to define subgraphs with a reduced number of nodes and edges. This is typically used by filters, which returns filtered graphs.
GraphModel
also contains the visible view, which is the main view by default but can be set to configure the view that is visualized.
What exactly contains the view? The complete hierarchy of nodes, the edges and meta-edges. Each view has separate hierarchy, therefore grouping and meta-edges are independent.
Note that nodes' id is unique, and is not touched by views.
Main or Visible View?
When you need to interact with the graph structure, you have the choice between working on the complete graph, i.e. the
main view, or the
visible view. In most cases, it's preferable to use the
visible view because your action will use the graph currently visualized, which has been potentially filtered by users on purpose.
To get the graph in the visible view, see {@link GraphModel#getGraphVisible()}.
Set the Visible View
This is the typical workflow for filtering a graph and display the results, as done by
FiltersAPI
.
- Create a new view, which duplicates the main view, with all nodes and edges in it.
- Remove nodes and edges in the view.
- Set the view as the curently visible view.
To set a view as the currently visible view, see {@link GraphModel#setVisibleView(org.gephi.graph.api.GraphView)}.
@author Mathieu Bastian