V
- the type of verticesE
- the type of edgespublic abstract class AbstractGraph<V,E extends Edge<V>> extends Object implements Graph<V,E>, GraphViewListener
Modifier and Type | Field and Description |
---|---|
protected Map<String,String> |
attributes |
protected Annotation |
graphAnnotation |
protected String |
graphName |
static String |
ZIP_PREFIX |
Modifier | Constructor and Description |
---|---|
protected |
AbstractGraph(GraphFactory factory)
Create a new graph with the default back-end.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addEdge(E edge)
Add an edge to this graph structure.
|
boolean |
addNode(V node)
Add a node to this graph structure
|
void |
addViewListener(GraphViewListener listener)
Add a listener for view change events.
|
boolean |
containsEdge(V from,
V to) |
boolean |
containsNode(V node) |
void |
copyView(Graph<V,E> src,
ViewCopyHelper<Graph<V,E>,V,E> helper)
Transfer view settings from a related graph.
|
void |
damage(Object o) |
protected abstract List<?> |
doMerge(Graph<V,E> graph)
Specialized method that execute the merging of the given graph with the current one
Must be override at specialized graph level
|
protected void |
doSave(OutputStreamWriter osw,
Collection<V> nodes,
Collection<E> edges)
save implementation for a specific graph type.
|
void |
fireGraphChange(GraphChangeType type,
Object data)
The graph has changed, all listeners will be notified.
|
void |
fireMetaChange() |
Annotation |
getAnnotation()
Give access to the annotation associated with this graph.
|
Map<String,String> |
getAttributes()
Retrieve graph-level attributes
|
protected EdgeAttributesReader |
getCachedEdgeAttributeReader() |
protected NodeAttributesReader |
getCachedNodeAttributeReader() |
Dimension |
getDimension()
Get the global bounds of the graph.
|
String |
getDisplayName(V node)
Retrieve the name to use when displaying a graph node.
|
E |
getEdge(V source,
V target) |
EdgeAttributesReader |
getEdgeAttributeReader()
Give access to the attribute reader of edges
|
Collection<E> |
getEdges() |
V |
getExistingNode(V node) |
protected GINMLWriter |
getGINMLWriter() |
String |
getGraphName()
Give access to the name of the graph
|
protected String |
getGraphZipName()
Return the zip extension for the graph type
|
Collection<E> |
getIncomingEdges(V node) |
NodeAttributesReader |
getNodeAttributeReader()
Give access to the attribute reader of vertices
|
V |
getNodeByName(String id)
Give access to the node named with the given name
|
int |
getNodeCount()
Return the number of node in this graph
|
abstract int |
getNodeOrderSize()
Return the size of the node order
|
Collection<V> |
getNodes()
Return the Collection of the graph nodes
|
Collection<E> |
getOutgoingEdges(V node) |
List<E> |
getShortestPath(V source,
V target)
Find the shortest path between the two given vertices
|
List<Set<V>> |
getStronglyConnectedComponents()
Return a list of set of node, each set containing a strongly connected component of the graph
|
StyleManager<V,E> |
getStyleManager()
Retrieve the style manager for this graph.
|
abstract Graph<V,E> |
getSubgraph(Collection<V> node,
Collection<E> edges)
Specialized method that build the sub-graph corresponding to the given lists of vertices and edges
The returned graph contains clones of the given graph objects structured as they are in the current graph
|
boolean |
isEmpty() |
List<?> |
merge(Graph<V,E> graph)
Launch the merge method on the specialized graph level, merging the current graph with the given one
and fire a graph change event
|
void |
refresh(Object o)
Declare an object visual setting change
|
boolean |
removeEdge(E edge)
Remove an edge from the graph.
|
boolean |
removeNode(V node)
Remove a node from the graph.
|
void |
repaint()
The full view was changed.
|
void |
save(String save_path)
Save this graph.
|
void |
save(String save_path,
Collection<V> vertices,
Collection<E> edges)
Save some components of this graph.
|
List<V> |
searchNodes(String regexp)
Search the vertices with ID matching the given regular expression.
|
void |
setAttribute(String name,
String value) |
void |
setGraphName(String graph_name)
changes (if success) the name associated with this graph.
|
public static final String ZIP_PREFIX
protected String graphName
protected Annotation graphAnnotation
protected AbstractGraph(GraphFactory factory)
public String getGraphName()
getGraphName
in interface GraphModel<V,E extends Edge<V>>
public void setGraphName(String graph_name) throws GsException
setGraphName
in interface GraphModel<V,E extends Edge<V>>
graph_name
- the new name.GsException
- if the name is invalid.public String getDisplayName(V node)
Graph
public Map<String,String> getAttributes()
Graph
protected String getGraphZipName()
public boolean addNode(V node)
public boolean addEdge(E edge)
public boolean removeNode(V node)
removeNode
in interface GraphModel<V,E extends Edge<V>>
node
- public boolean removeEdge(E edge)
removeEdge
in interface GraphModel<V,E extends Edge<V>>
edge
- public int getNodeCount()
GraphModel
getNodeCount
in interface GraphModel<V,E extends Edge<V>>
public Collection<E> getEdges()
public Collection<V> getNodes()
GraphModel
public List<Set<V>> getStronglyConnectedComponents()
getStronglyConnectedComponents
in interface GraphModel<V,E extends Edge<V>>
public V getNodeByName(String id)
getNodeByName
in interface GraphModel<V,E extends Edge<V>>
id
- name of a nodepublic abstract int getNodeOrderSize()
getNodeOrderSize
in interface GraphModel<V,E extends Edge<V>>
public List<V> searchNodes(String regexp)
searchNodes
in interface GraphModel<V,E extends Edge<V>>
regexp
- the regular expression node ID must match to be selectedpublic boolean containsNode(V node)
containsNode
in interface GraphModel<V,E extends Edge<V>>
public V getExistingNode(V node)
getExistingNode
in interface GraphModel<V,E extends Edge<V>>
public boolean containsEdge(V from, V to)
containsEdge
in interface GraphModel<V,E extends Edge<V>>
public Collection<E> getIncomingEdges(V node)
getIncomingEdges
in interface GraphModel<V,E extends Edge<V>>
public Collection<E> getOutgoingEdges(V node)
getOutgoingEdges
in interface GraphModel<V,E extends Edge<V>>
public List<E> getShortestPath(V source, V target)
GraphModel
getShortestPath
in interface GraphModel<V,E extends Edge<V>>
source
- the node at the beginning of the searched pathtarget
- the node at the end of the searched pathpublic void addViewListener(GraphViewListener listener)
Graph
public void refresh(Object o)
refresh
in interface GraphViewListener
o
- public void repaint()
GraphViewListener
repaint
in interface GraphViewListener
public void damage(Object o)
public StyleManager<V,E> getStyleManager()
Graph
public EdgeAttributesReader getEdgeAttributeReader()
Graph
public NodeAttributesReader getNodeAttributeReader()
Graph
protected EdgeAttributesReader getCachedEdgeAttributeReader()
protected NodeAttributesReader getCachedNodeAttributeReader()
public Dimension getDimension()
Graph
public boolean isEmpty()
public List<?> merge(Graph<V,E> graph)
protected abstract List<?> doMerge(Graph<V,E> graph)
graph
- public abstract Graph<V,E> getSubgraph(Collection<V> node, Collection<E> edges)
getSubgraph
in interface GraphModel<V,E extends Edge<V>>
node
- the list of node to include in the desired sub-graphedges
- the list of edges to include in the sub-graphpublic Annotation getAnnotation()
getAnnotation
in interface GraphModel<V,E extends Edge<V>>
public void save(String save_path) throws GsException
Graph
public void save(String save_path, Collection<V> vertices, Collection<E> edges) throws GsException
Graph
public void copyView(Graph<V,E> src, ViewCopyHelper<Graph<V,E>,V,E> helper)
Graph
protected final void doSave(OutputStreamWriter osw, Collection<V> nodes, Collection<E> edges) throws GsException
osw
- stream writernodes
- vertices that should be saved (can not be null)edges
- edges that should be saved (can not be null)GsException
protected GINMLWriter getGINMLWriter()
public void fireMetaChange()
public void fireGraphChange(GraphChangeType type, Object data)
Graph
Copyright © 2005–2020. All rights reserved.