Package jadex.tools.comanalyzer.graph
Class MultidirectedMultiGraph
- java.lang.Object
-
- edu.uci.ics.jung.graph.AbstractGraph<V,E>
-
- edu.uci.ics.jung.graph.SparseGraph
-
- jadex.tools.comanalyzer.graph.MultidirectedMultiGraph
-
- All Implemented Interfaces:
edu.uci.ics.jung.graph.Graph
,edu.uci.ics.jung.graph.Hypergraph
,java.io.Serializable
public class MultidirectedMultiGraph extends edu.uci.ics.jung.graph.SparseGraph implements edu.uci.ics.jung.graph.Graph, java.io.Serializable
Implementation of an Graph that can be used as a simple or a multi graph with directed and undirected edges.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
INCIDENT
Indicates incident (undirected) edges in the mapprotected static int
INCOMING
Indicates incoming edges in the mapprotected java.util.Map
mdirected_edges
Map of directed edges to incident vertex setsprotected java.util.Map
mundirected_edges
Map of undirected edges to incident vertex setsprotected java.util.Map
mvertex_maps
Map of vertices to adjacency maps of vertices to {incoming, outgoing, incident} edgesprotected static int
OUTGOING
Indicates outgoing edges in the map
-
Constructor Summary
Constructors Constructor Description MultidirectedMultiGraph()
Creates a new graph.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addEdge(java.lang.Object edge, edu.uci.ics.jung.graph.util.Pair endpoints)
Adds a directed edge to the graph.boolean
addEdge(java.lang.Object edge, edu.uci.ics.jung.graph.util.Pair endpoints, edu.uci.ics.jung.graph.util.EdgeType edgeType)
Adds a edge to the graph with a specific edge type.boolean
addEdge(java.lang.Object e, java.lang.Object v1, java.lang.Object v2)
Adds a directed edge to the graph.boolean
addEdge(java.lang.Object e, java.lang.Object v1, java.lang.Object v2, edu.uci.ics.jung.graph.util.EdgeType edgeType)
Adds a edge to the graph with a specific edge type.boolean
addVertex(java.lang.Object vertex)
Adds a vertex to the graph.boolean
containsEdge(java.lang.Object edge)
Returnstrue
if the graph contains the edge.boolean
containsVertex(java.lang.Object vertex)
Returnstrue
if the graph contains the vertex.static edu.uci.ics.jung.graph.Graph
create()
Returns a new MultidirectedMultiGraph.int
degree(java.lang.Object vertex)
Returns the degree (number of incident edges) of a vertex.java.lang.Object
findEdge(java.lang.Object v1, java.lang.Object v2)
Returns the first edge between the two vertices.java.util.Collection
findEdgeSet(java.lang.Object v1, java.lang.Object v2)
Returns a collection of edges between the two vertices.java.lang.Object
getDest(java.lang.Object directed_edge)
Returns the destination of a directed edge.int
getEdgeCount()
java.util.Collection
getEdges()
Returns all edges of the graph.java.util.Collection
getEdges(edu.uci.ics.jung.graph.util.EdgeType edgeType)
Returns the edges for a given edge type.edu.uci.ics.jung.graph.util.EdgeType
getEdgeType(java.lang.Object edge)
Returns the edge type of en edge.edu.uci.ics.jung.graph.util.Pair
getEndpoints(java.lang.Object edge)
Returns the endpoints of the edge.static org.apache.commons.collections15.Factory
getFactory()
Returns the factory for the graph.protected java.util.Collection
getIncident_internal(java.lang.Object vertex)
Returns the incident edges of the vertexjava.util.Collection
getIncidentEdges(java.lang.Object vertex)
Returns the incident edges of the vertex.protected java.util.Collection
getIncoming_internal(java.lang.Object vertex)
Returns the incoming edges of the vertexjava.util.Collection
getInEdges(java.lang.Object vertex)
Returns the incoming edges of the vertex.java.util.Collection
getNeighbors(java.lang.Object vertex)
Returns the neighbor vertices of a given vertex.java.util.Collection
getOutEdges(java.lang.Object vertex)
Returns the outgoing edges of the vertex.protected java.util.Collection
getOutgoing_internal(java.lang.Object vertex)
Returns the outgoing edges of the vertexjava.util.Collection
getPredecessors(java.lang.Object vertex)
Returns the vertices that have an outgoing edge to the given vertex.java.lang.Object
getSource(java.lang.Object directed_edge)
Returns the source of a directed edge.java.util.Collection
getSuccessors(java.lang.Object vertex)
Returns the vertices that have an incoming edge from the given vertex.int
getVertexCount()
java.util.Collection
getVertices()
Returns all vertices of the graph.boolean
isDest(java.lang.Object vertex, java.lang.Object edge)
Returnstrue
if the vertex is the destination of the edge.boolean
isSource(java.lang.Object vertex, java.lang.Object edge)
Returnstrue
if the vertex is the source of the edge.boolean
removeEdge(java.lang.Object edge)
Removes a edge from the graph.boolean
removeVertex(java.lang.Object vertex)
Removes a vertex from the graph.-
Methods inherited from class edu.uci.ics.jung.graph.AbstractGraph
addEdge, addEdge, getIncidentCount, getIncidentVertices, getNeighborCount, getOpposite, getPredecessorCount, getSuccessorCount, getValidatedEndpoints, inDegree, isIncident, isNeighbor, isPredecessor, isSuccessor, outDegree, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
INCOMING
protected static final int INCOMING
Indicates incoming edges in the map- See Also:
- Constant Field Values
-
OUTGOING
protected static final int OUTGOING
Indicates outgoing edges in the map- See Also:
- Constant Field Values
-
INCIDENT
protected static final int INCIDENT
Indicates incident (undirected) edges in the map- See Also:
- Constant Field Values
-
mvertex_maps
protected java.util.Map mvertex_maps
Map of vertices to adjacency maps of vertices to {incoming, outgoing, incident} edges
-
mdirected_edges
protected java.util.Map mdirected_edges
Map of directed edges to incident vertex sets
-
mundirected_edges
protected java.util.Map mundirected_edges
Map of undirected edges to incident vertex sets
-
-
Method Detail
-
getFactory
public static org.apache.commons.collections15.Factory getFactory()
Returns the factory for the graph.- Returns:
- The Factory for the graph..
-
create
public static edu.uci.ics.jung.graph.Graph create()
Returns a new MultidirectedMultiGraph.- Returns:
- The MultidirectedMultiGraph.
-
addEdge
public boolean addEdge(java.lang.Object edge, edu.uci.ics.jung.graph.util.Pair endpoints)
Adds a directed edge to the graph.- Overrides:
addEdge
in classedu.uci.ics.jung.graph.AbstractGraph
- Parameters:
edge
- The edge.endpoints
- The endpoints.- Returns:
true
if success.
-
addEdge
public boolean addEdge(java.lang.Object edge, edu.uci.ics.jung.graph.util.Pair endpoints, edu.uci.ics.jung.graph.util.EdgeType edgeType)
Adds a edge to the graph with a specific edge type.- Overrides:
addEdge
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
edge
- The edge.endpoints
- The endpoints.edgeType
- The edge type.- Returns:
true
if success.
-
addEdge
public boolean addEdge(java.lang.Object e, java.lang.Object v1, java.lang.Object v2)
Adds a directed edge to the graph.- Specified by:
addEdge
in interfaceedu.uci.ics.jung.graph.Graph
- Overrides:
addEdge
in classedu.uci.ics.jung.graph.AbstractGraph
- Parameters:
edge
- The edge.v1
- The first vertex.v2
- The second vertex.- Returns:
true
if success.
-
addEdge
public boolean addEdge(java.lang.Object e, java.lang.Object v1, java.lang.Object v2, edu.uci.ics.jung.graph.util.EdgeType edgeType)
Adds a edge to the graph with a specific edge type.- Specified by:
addEdge
in interfaceedu.uci.ics.jung.graph.Graph
- Overrides:
addEdge
in classedu.uci.ics.jung.graph.AbstractGraph
- Parameters:
edge
- The edge.v1
- The first vertex.v2
- The second vertex..edgeType
- The edge type.- Returns:
true
if success.
-
findEdge
public java.lang.Object findEdge(java.lang.Object v1, java.lang.Object v2)
Returns the first edge between the two vertices.- Specified by:
findEdge
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
findEdge
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
v1
- The first vertex.v2
- The second vertex.- Returns:
- The edge or
null
if there is no incident edge between the vertices.
-
findEdgeSet
public java.util.Collection findEdgeSet(java.lang.Object v1, java.lang.Object v2)
Returns a collection of edges between the two vertices.- Specified by:
findEdgeSet
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
findEdgeSet
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
v1
- The first vertex.v2
- The second vertex.- Returns:
- The collection of edges or
null
if there is no incident edge between the vertices.
-
getInEdges
public java.util.Collection getInEdges(java.lang.Object vertex)
Returns the incoming edges of the vertex.- Specified by:
getInEdges
in interfaceedu.uci.ics.jung.graph.Graph
- Specified by:
getInEdges
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getInEdges
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertx- Returns:
- The collection of edges.
-
getOutEdges
public java.util.Collection getOutEdges(java.lang.Object vertex)
Returns the outgoing edges of the vertex.- Specified by:
getOutEdges
in interfaceedu.uci.ics.jung.graph.Graph
- Specified by:
getOutEdges
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getOutEdges
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertx- Returns:
- The collection of edges.
-
getPredecessors
public java.util.Collection getPredecessors(java.lang.Object vertex)
Returns the vertices that have an outgoing edge to the given vertex.- Specified by:
getPredecessors
in interfaceedu.uci.ics.jung.graph.Graph
- Specified by:
getPredecessors
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getPredecessors
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.- Returns:
- The collection of vertices.
-
getSuccessors
public java.util.Collection getSuccessors(java.lang.Object vertex)
Returns the vertices that have an incoming edge from the given vertex.- Specified by:
getSuccessors
in interfaceedu.uci.ics.jung.graph.Graph
- Specified by:
getSuccessors
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getSuccessors
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.- Returns:
- The collection of vertices.
-
getEdges
public java.util.Collection getEdges(edu.uci.ics.jung.graph.util.EdgeType edgeType)
Returns the edges for a given edge type.- Specified by:
getEdges
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getEdges
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
edgeType
- The edge tzpe.- Returns:
- The collection of edges.
-
getEndpoints
public edu.uci.ics.jung.graph.util.Pair getEndpoints(java.lang.Object edge)
Returns the endpoints of the edge.- Specified by:
getEndpoints
in interfaceedu.uci.ics.jung.graph.Graph
- Overrides:
getEndpoints
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
edge
- The edge.- Returns:
- The endpoints.
-
getEdgeType
public edu.uci.ics.jung.graph.util.EdgeType getEdgeType(java.lang.Object edge)
Returns the edge type of en edge.- Specified by:
getEdgeType
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getEdgeType
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
edge
- The edge.- Returns:
- The edge type.
-
getSource
public java.lang.Object getSource(java.lang.Object directed_edge)
Returns the source of a directed edge.- Specified by:
getSource
in interfaceedu.uci.ics.jung.graph.Graph
- Specified by:
getSource
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getSource
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
directed_edge
- The edge.- Returns:
- The vertex.
-
getDest
public java.lang.Object getDest(java.lang.Object directed_edge)
Returns the destination of a directed edge.- Specified by:
getDest
in interfaceedu.uci.ics.jung.graph.Graph
- Specified by:
getDest
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getDest
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
directed_edge
- The edge.- Returns:
- The vertex.
-
isSource
public boolean isSource(java.lang.Object vertex, java.lang.Object edge)
Returnstrue
if the vertex is the source of the edge.- Specified by:
isSource
in interfaceedu.uci.ics.jung.graph.Graph
- Overrides:
isSource
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.edge
- The edge.- Returns:
true
if the vertex is the source.
-
isDest
public boolean isDest(java.lang.Object vertex, java.lang.Object edge)
Returnstrue
if the vertex is the destination of the edge.- Specified by:
isDest
in interfaceedu.uci.ics.jung.graph.Graph
- Overrides:
isDest
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.edge
- The edge.- Returns:
true
if the vertex is the destination.
-
getEdges
public java.util.Collection getEdges()
Returns all edges of the graph.- Specified by:
getEdges
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getEdges
in classedu.uci.ics.jung.graph.SparseGraph
- Returns:
- The collection of edges.
-
getVertices
public java.util.Collection getVertices()
Returns all vertices of the graph.- Specified by:
getVertices
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getVertices
in classedu.uci.ics.jung.graph.SparseGraph
- Returns:
- The collection of vertices.
-
containsVertex
public boolean containsVertex(java.lang.Object vertex)
Returnstrue
if the graph contains the vertex.- Specified by:
containsVertex
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
containsVertex
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.- Returns:
true
if the vertex is in the graph.
-
containsEdge
public boolean containsEdge(java.lang.Object edge)
Returnstrue
if the graph contains the edge.- Specified by:
containsEdge
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
containsEdge
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
edge
- The edge.- Returns:
true
if the edge is in the graph.
-
getEdgeCount
public int getEdgeCount()
- Specified by:
getEdgeCount
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getEdgeCount
in classedu.uci.ics.jung.graph.SparseGraph
- Returns:
- The edge count.
-
getVertexCount
public int getVertexCount()
- Specified by:
getVertexCount
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getVertexCount
in classedu.uci.ics.jung.graph.SparseGraph
- Returns:
- The vertex count.
-
getNeighbors
public java.util.Collection getNeighbors(java.lang.Object vertex)
Returns the neighbor vertices of a given vertex.- Specified by:
getNeighbors
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getNeighbors
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.- Returns:
- The collection of neighbors.
-
degree
public int degree(java.lang.Object vertex)
Returns the degree (number of incident edges) of a vertex.- Specified by:
degree
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
degree
in classedu.uci.ics.jung.graph.AbstractGraph
- Parameters:
vertex
- The vertex.- Returns:
- The degree.
-
getIncidentEdges
public java.util.Collection getIncidentEdges(java.lang.Object vertex)
Returns the incident edges of the vertex.- Specified by:
getIncidentEdges
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
getIncidentEdges
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.- Returns:
- The collection of edges.
-
addVertex
public boolean addVertex(java.lang.Object vertex)
Adds a vertex to the graph.- Specified by:
addVertex
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
addVertex
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.- Returns:
true
if success.
-
removeVertex
public boolean removeVertex(java.lang.Object vertex)
Removes a vertex from the graph.- Specified by:
removeVertex
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
removeVertex
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
vertex
- The vertex.- Returns:
true
if success
-
removeEdge
public boolean removeEdge(java.lang.Object edge)
Removes a edge from the graph.- Specified by:
removeEdge
in interfaceedu.uci.ics.jung.graph.Hypergraph
- Overrides:
removeEdge
in classedu.uci.ics.jung.graph.SparseGraph
- Parameters:
edge
- The edge.- Returns:
true
if success
-
getIncoming_internal
protected java.util.Collection getIncoming_internal(java.lang.Object vertex)
Returns the incoming edges of the vertex- Parameters:
vertex
- The vertex.- Returns:
- The collection of edges.
-
getIncident_internal
protected java.util.Collection getIncident_internal(java.lang.Object vertex)
Returns the incident edges of the vertex- Parameters:
vertex
- The vertex.- Returns:
- The collection of edges.
-
getOutgoing_internal
protected java.util.Collection getOutgoing_internal(java.lang.Object vertex)
Returns the outgoing edges of the vertex- Parameters:
vertex
- The vertex.- Returns:
- The collection of edges.
-
-