public abstract class AbstractGraphMLDiagram extends AbstractGraph<IGraphMLNode,GraphMLEdge> implements NodeParent, java.lang.Cloneable
Modifier and Type | Field and Description |
---|---|
protected java.util.SortedMap<java.lang.String,IGraphMLNode> |
children
The children nodes.
|
protected EdgeType |
defaultEdgeType
The diagram edges type.
|
protected DiagramDefaults |
defaults
The diagram defaults.
|
protected java.util.SortedMap<java.lang.String,GraphMLEdge> |
edges
The edges.
|
protected java.util.SortedMap<java.lang.String,GraphMLGroupNode> |
groupNodes
The node groups.
|
protected java.util.SortedMap<java.lang.String,IGraphMLNode> |
nodes
The nodes.
|
Constructor and Description |
---|
AbstractGraphMLDiagram() |
AbstractGraphMLDiagram(DiagramDefaults defaults) |
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(IGraphMLNode node)
Adds a node to this graph.
|
boolean |
addEdge(GraphMLEdge edge,
IGraphMLNode source,
IGraphMLNode target)
Add an edge from a source to a target.
|
GraphMLEdge |
addEdge(IGraphMLNode source,
IGraphMLNode target)
Add an edge from a source to a target.
|
GraphMLEdge |
addEdgeFromTemplate(IGraphMLNode source,
IGraphMLNode target,
java.lang.String id)
Add an edge from a source to a target, using a template.
|
boolean |
addEdgeWithEndpoints(GraphMLEdge edge,
Pair<? extends IGraphMLNode> endpoints,
EdgeType edgeType)
Add an edgeto this graph with the specified endpoints and EdgeType.
|
GraphMLGroupNode |
addGroupNode()
Add a group node with an id specified automatically.
|
GraphMLGroupNode |
addGroupNode(java.lang.String id)
Add a group node with a specified id.
|
GraphMLGroupNode |
addGroupNodeFromTemplate(java.lang.String id)
Add a group node, using a template.
|
GraphMLNode |
addNode()
Add a node with an id specified automatically.
|
boolean |
addNode(IGraphMLNode node)
Adds a node to this graph.
|
boolean |
addNode(IGraphMLNode node,
boolean acceptNewID)
Adds a node to this graph.
|
GraphMLNode |
addNode(java.lang.String id)
Add a node with a specified id.
|
GraphMLNode |
addNodeFromTemplate(java.lang.String id)
Add a node, using a template.
|
boolean |
addVertex(IGraphMLNode vertex)
Adds
vertex to this graph. |
boolean |
addVertex(IGraphMLNode vertex,
boolean acceptNewID)
Adds
vertex to this graph. |
AbstractGraphMLDiagram |
clone() |
boolean |
containsEdge(GraphMLEdge edge)
Returns true if this graph's edge collection contains
edge . |
boolean |
containsVertex(IGraphMLNode vertex)
Returns true if this graph's vertex collection contains
vertex . |
int |
countEdges()
Return the number of edges.
|
int |
countGroupNodes()
Return the number of group nodes.
|
int |
countNodes()
Return the number of nodes.
|
void |
detachNode(AbstractGraphMLNode node)
Detach a node from the diagram.
|
java.util.SortedMap<java.lang.String,IGraphMLNode> |
getChildren()
Return the nodes.
|
EdgeType |
getDefaultEdgeType()
Returns the default edge type for this graph.
|
DiagramDefaults |
getDefaults()
Return the diagram defaults.
|
IGraphMLNode |
getDest(GraphMLEdge edge)
If
directed_edge is a directed edge in this graph, returns the destination; otherwise returns null . |
AbstractGraphMLDiagram |
getDiagram()
Return this diagram.
|
int |
getEdgeCount()
Returns the number of edges in this graph.
|
int |
getEdgeCount(EdgeType edgeType)
Returns the number of edges in this graph.
|
java.util.SortedMap<java.lang.String,GraphMLEdge> |
getEdges()
Return the edges.
|
java.util.Collection<GraphMLEdge> |
getEdges(EdgeType edgeType)
Returns the collection of edges in this graph which are of type
edgeType . |
java.util.Collection<GraphMLEdge> |
getEdgesView()
Returns a view of all edges in this graph.
|
EdgeType |
getEdgeType(GraphMLEdge edge)
Returns the edge type of
edge in this graph. |
Pair<IGraphMLNode> |
getEndpoints(GraphMLEdge edge)
Returns the endpoints of
edge as a Pair<V> . |
java.util.SortedMap<java.lang.String,GraphMLGroupNode> |
getGroupNodes()
Return the group nodes.
|
java.util.Collection<GraphMLEdge> |
getIncidentEdges(IGraphMLNode vertex)
Returns the collection of edges in this graph which are connected to
vertex . |
java.util.Collection<GraphMLEdge> |
getInEdges(IGraphMLNode vertex)
Returns a
Collection view of the incoming edges incident to vertex in this graph. |
java.util.Collection<IGraphMLNode> |
getNeighbors(IGraphMLNode vertex)
Returns the collection of vertices which are connected to
vertex via any edges in this graph. |
java.util.SortedMap<java.lang.String,IGraphMLNode> |
getNodes()
Return the nodes.
|
java.util.Collection<GraphMLEdge> |
getOutEdges(IGraphMLNode vertex)
Returns a
Collection view of the outgoing edges incident to vertex in this graph. |
java.util.Collection<IGraphMLNode> |
getPredecessors(IGraphMLNode vertex)
Returns a
Collection view of the predecessors of vertex in this graph. |
IGraphMLNode |
getSource(GraphMLEdge edge)
If
directed_edge is a directed edge in this graph, returns the source; otherwise returns null . |
java.util.Collection<IGraphMLNode> |
getSuccessors(IGraphMLNode vertex)
Returns a
Collection view of the successors of vertex in this graph. |
protected java.lang.String |
getUnusedNodeID(java.lang.String id)
Return an unused id for nodes.
|
int |
getVertexCount()
Returns the number of vertices in this graph.
|
java.util.Collection<IGraphMLNode> |
getVerticesView()
Returns a view of all vertices in this graph.
|
boolean |
hasGroupNodes()
Return true if there are group nodes.
|
boolean |
isDest(IGraphMLNode vertex,
GraphMLEdge edge)
Returns
true if vertex is the destination of edge . |
boolean |
isSource(IGraphMLNode vertex,
GraphMLEdge edge)
Returns
true if vertex is the source of edge . |
boolean |
removeEdge(GraphMLEdge edge)
Removes
edge from this graph. |
boolean |
removeVertex(IGraphMLNode vertex)
Removes
vertex from this graph. |
void |
setDefaultEdgeType(EdgeType edgeType)
Set the default edge type for this graph.
|
void |
setDefaults(DiagramDefaults defaults)
Set the diagram defaults.
|
addEdge, addEdgeWithEndPoints, addEdgeWithVertices, addEdgeWithVertices, degree, findEdge, findEdgeSet, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addGroupNodeFromTemplateWithLabel, addGroupNodeWithLabel, addNodeFromTemplateWithLabel, addNodeWithLabel
protected java.util.SortedMap<java.lang.String,GraphMLGroupNode> groupNodes
protected java.util.SortedMap<java.lang.String,IGraphMLNode> nodes
protected java.util.SortedMap<java.lang.String,IGraphMLNode> children
protected java.util.SortedMap<java.lang.String,GraphMLEdge> edges
protected EdgeType defaultEdgeType
protected DiagramDefaults defaults
public AbstractGraphMLDiagram()
public AbstractGraphMLDiagram(DiagramDefaults defaults)
public void setDefaults(DiagramDefaults defaults)
defaults
- the diagram defaults.public DiagramDefaults getDefaults()
public int countNodes()
countNodes
in interface NodeParent
public int countGroupNodes()
countGroupNodes
in interface NodeParent
public boolean hasGroupNodes()
hasGroupNodes
in interface NodeParent
public AbstractGraphMLDiagram getDiagram()
getDiagram
in interface NodeParent
public int countEdges()
public void detachNode(AbstractGraphMLNode node)
node
- the nodepublic AbstractGraphMLDiagram clone()
clone
in class java.lang.Object
public boolean addEdgeWithEndpoints(GraphMLEdge edge, Pair<? extends IGraphMLNode> endpoints, EdgeType edgeType)
addEdgeWithEndpoints
in class AbstractGraph<IGraphMLNode,GraphMLEdge>
edge
- the edgeendpoints
- the endPointsedgeType
- the edge typepublic Pair<IGraphMLNode> getEndpoints(GraphMLEdge edge)
edge
as a Pair<V>
.getEndpoints
in interface Graph<IGraphMLNode,GraphMLEdge>
edge
- the edge whose endpoints are to be returnededge
public boolean isDest(IGraphMLNode vertex, GraphMLEdge edge)
true
if vertex
is the destination of edge
. Equivalent to
getDest(edge).equals(vertex)
.isDest
in interface Graph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex to be queriededge
- the edge to be queriedtrue
iff vertex
is the destination of edge
public boolean isSource(IGraphMLNode vertex, GraphMLEdge edge)
true
if vertex
is the source of edge
. Equivalent to
getSource(edge).equals(vertex)
.isSource
in interface Graph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex to be queriededge
- the edge to be queriedtrue
iff vertex
is the source of edge
public IGraphMLNode getDest(GraphMLEdge edge)
directed_edge
is a directed edge in this graph, returns the destination; otherwise returns null
. The
destination of a directed edge d
is defined to be the vertex incident to d
for which d
is an
incoming edge. directed_edge
is guaranteed to be a directed edge if its EdgeType
is DIRECTED
.getDest
in interface Graph<IGraphMLNode,GraphMLEdge>
getDest
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
edge
- directed_edge
if it is a directed edge in this graph, or null
otherwisepublic IGraphMLNode getSource(GraphMLEdge edge)
directed_edge
is a directed edge in this graph, returns the source; otherwise returns null
. The source of
a directed edge d
is defined to be the vertex for which d
is an outgoing edge. directed_edge
is
guaranteed to be a directed edge if its EdgeType
is DIRECTED
.getSource
in interface Graph<IGraphMLNode,GraphMLEdge>
getSource
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
edge
- directed_edge
if it is a directed edge in this graph, or null
otherwisepublic java.util.Collection<IGraphMLNode> getSuccessors(IGraphMLNode vertex)
Collection
view of the successors of vertex
in this graph. A successor of vertex
is
defined as a vertex v
which is connected to vertex
by an edge e
, where e
is an
incoming edge of v
and an outgoing edge of vertex
.getSuccessors
in interface Graph<IGraphMLNode,GraphMLEdge>
getSuccessors
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex whose predecessors are to be returnedCollection
view of the successors of vertex
in this graphpublic java.util.Collection<IGraphMLNode> getPredecessors(IGraphMLNode vertex)
Collection
view of the predecessors of vertex
in this graph. A predecessor of vertex
is defined as a vertex v
which is connected to vertex
by an edge e
, where e
is an
outgoing edge of v
and an incoming edge of vertex
.getPredecessors
in interface Graph<IGraphMLNode,GraphMLEdge>
getPredecessors
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex whose predecessors are to be returnedCollection
view of the predecessors of vertex
in this graphpublic java.util.Collection<GraphMLEdge> getInEdges(IGraphMLNode vertex)
Collection
view of the incoming edges incident to vertex
in this graph.getInEdges
in interface Graph<IGraphMLNode,GraphMLEdge>
getInEdges
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex whose incoming edges are to be returnedCollection
view of the incoming edges incident to vertex
in this graphpublic java.util.Collection<GraphMLEdge> getOutEdges(IGraphMLNode vertex)
Collection
view of the outgoing edges incident to vertex
in this graph.getOutEdges
in interface Graph<IGraphMLNode,GraphMLEdge>
getOutEdges
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex whose outgoing edges are to be returnedCollection
view of the outgoing edges incident to vertex
in this graphpublic int getEdgeCount()
getEdgeCount
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
public int getEdgeCount(EdgeType edgeType)
getEdgeCount
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
edgeType
- the edge typepublic java.util.Collection<GraphMLEdge> getEdges(EdgeType edgeType)
edgeType
.getEdges
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
edgeType
- the type of edges to be returnededge_type
, or null
if the graph does not accept edges of
this typeEdgeType
public void setDefaultEdgeType(EdgeType edgeType)
edgeType
- the default edge type for this graphpublic EdgeType getDefaultEdgeType()
getDefaultEdgeType
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
public EdgeType getEdgeType(GraphMLEdge edge)
edge
in this graph.getEdgeType
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
edge
- EdgeType
of edge
, or null
if edge
has no defined typepublic boolean removeEdge(GraphMLEdge edge)
edge
from this graph. Fails if edge
is null, or is otherwise not an element of this graph.removeEdge
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
edge
- the edge to removetrue
if the removal is successful, false
otherwisepublic boolean removeVertex(IGraphMLNode vertex)
vertex
from this graph. As a side effect, removes any edges e
incident to vertex
if the
removal of vertex
would cause e
to be incident to an illegal number of vertices. (Thus, for example,
incident hyperedges are not removed, but incident edges--which must be connected to a vertex at both endpoints--are removed.)
Fails under the following circumstances:
vertex
is not an element of this graphvertex
is null
removeVertex
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex to removetrue
if the removal is successful, false
otherwisepublic boolean addVertex(IGraphMLNode vertex)
vertex
to this graph. Fails if vertex
is null or already in the graph.addVertex
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex to addtrue
if the add is successful, and false
otherwisejava.lang.IllegalArgumentException
- if vertex
is null
public boolean addNode(IGraphMLNode node)
addVertex(org.girod.jgraphml.model.IGraphMLNode)
.node
- the vertex to addtrue
if the add is successful, and false
otherwisejava.lang.IllegalArgumentException
- if vertex
is null
public boolean addChild(IGraphMLNode node)
addVertex(org.girod.jgraphml.model.IGraphMLNode)
.addChild
in interface NodeParent
node
- the node to addtrue
if the add is successful, and false
otherwisejava.lang.IllegalArgumentException
- if node
is null
public boolean addNode(IGraphMLNode node, boolean acceptNewID)
addVertex(org.girod.jgraphml.model.IGraphMLNode, boolean)
.node
- the vertex to addacceptNewID
- if true, accept to rename the vertex / node if the ID aleady existstrue
if the add is successful, and false
otherwisejava.lang.IllegalArgumentException
- if vertex
is null
public GraphMLNode addNode(java.lang.String id)
addNode
in interface NodeParent
id
- the node idpublic GraphMLGroupNode addGroupNode(java.lang.String id)
addGroupNode
in interface NodeParent
id
- the group node idpublic GraphMLNode addNode()
addNode
in interface NodeParent
public GraphMLNode addNodeFromTemplate(java.lang.String id) throws TemplateAccessException
addNodeFromTemplate
in interface NodeParent
id
- the template idTemplateAccessException
public GraphMLGroupNode addGroupNode()
addGroupNode
in interface NodeParent
public GraphMLGroupNode addGroupNodeFromTemplate(java.lang.String id) throws TemplateAccessException
addGroupNodeFromTemplate
in interface NodeParent
id
- the template idTemplateAccessException
public java.util.SortedMap<java.lang.String,IGraphMLNode> getNodes()
public java.util.SortedMap<java.lang.String,IGraphMLNode> getChildren()
getChildren
in interface NodeParent
public java.util.SortedMap<java.lang.String,GraphMLGroupNode> getGroupNodes()
getGroupNodes
in interface NodeParent
public java.util.SortedMap<java.lang.String,GraphMLEdge> getEdges()
public boolean addVertex(IGraphMLNode vertex, boolean acceptNewID) throws TemplateAccessException
vertex
to this graph. Fails if vertex
is null or already in the graph. Accept to rename the vertex /
node depending on the acceptNewID is true.vertex
- the vertex to addacceptNewID
- if true, accept to rename the vertex / node if the ID aleady existstrue
if the add is successful, and false
otherwisejava.lang.IllegalArgumentException
- if vertex
is null
TemplateAccessException
public boolean addEdge(GraphMLEdge edge, IGraphMLNode source, IGraphMLNode target) throws TemplateAccessException
addEdge
in interface Graph<IGraphMLNode,GraphMLEdge>
addEdge
in class AbstractGraph<IGraphMLNode,GraphMLEdge>
edge
- the edgesource
- the edge sourcetarget
- the edge targetTemplateAccessException
Graph.addEdge(Object, Object, Object, EdgeType)
public GraphMLEdge addEdge(IGraphMLNode source, IGraphMLNode target)
source
- the edge sourcetarget
- the edge targetpublic GraphMLEdge addEdgeFromTemplate(IGraphMLNode source, IGraphMLNode target, java.lang.String id) throws TemplateAccessException
source
- the edge sourcetarget
- the edge targetid
- the template idTemplateAccessException
protected java.lang.String getUnusedNodeID(java.lang.String id)
id
- the idpublic java.util.Collection<GraphMLEdge> getIncidentEdges(IGraphMLNode vertex)
vertex
.getIncidentEdges
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex whose incident edges are to be returnedvertex
, or null
if vertex
is not presentpublic java.util.Collection<IGraphMLNode> getNeighbors(IGraphMLNode vertex)
vertex
via any edges in this graph. If vertex
is
connected to itself with a self-loop, then it will be included in the collection returned.getNeighbors
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex whose neighbors are to be returnedvertex
, or null
if vertex
is not
presentpublic int getVertexCount()
getVertexCount
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
public boolean containsEdge(GraphMLEdge edge)
edge
. Equivalent to getEdges().contains(edge)
.containsEdge
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
edge
- the edge whose presence is being queriededge
public boolean containsVertex(IGraphMLNode vertex)
vertex
. Equivalent to
getVertices().contains(vertex)
.containsVertex
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
vertex
- the vertex whose presence is being queriedvertex
public java.util.Collection<IGraphMLNode> getVerticesView()
Collection
contract, and therefore makes no
guarantees about the ordering of the vertices within the set.getVerticesView
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
Collection
view of all vertices in this graphpublic java.util.Collection<GraphMLEdge> getEdgesView()
Collection
contract, and therefore makes no
guarantees about the ordering of the vertices within the set.getEdgesView
in interface Hypergraph<IGraphMLNode,GraphMLEdge>
Collection
view of all edges in this graphCopyright © 2021, 2022 Herve Girod. All Rights Reserved. Documentation and source under the BSD 3-Clause licence