Package org.tweetyproject.graphs
Interface DirHyperGraph<T extends Node>
- Type Parameters:
T
- A Node.
- All Superinterfaces:
GeneralGraph<T>
,Iterable<T>
- All Known Implementing Classes:
SetAf
Interface for directed hypergraph
- Author:
- Sebastian Franke
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
When inverting a DirHyperGraph, ignore self loops (don't add and don't remove)static final int
When inverting a DirHyperGraph, deal with self loops like ordinary edges (add if not present and remove if present)static final int
When inverting a DirHyperGraph, simple remove self loops, but don't add new ones. -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(GeneralEdge<T> edge) Adds the given edge to this DirHyperGraph.boolean
Adds the given node to this DirHyperGraph.boolean
areAdjacent
(T a, T b) Returns "true" iff the two nodes are connected by a directed edge from a to b or an undirected edge.boolean
Returns "true" when this DirHyperGraph contains the given node or edge.boolean
existsDirectedPath
(T node1, T node2) Checks whether there is a (directed) path from node1 to node2.Returns the adjacency matrix of this DirHyperGraph (the order of the nodes is the same as returned by "iterator()").getChildren
(Node node) Returns the set of children (node connected via an undirected edge or a directed edge where the given node is the parent) of the given node.getComplementGraph
(int selfloops) Returns the complement DirHyperGraph of this DirHyperGraph, i.e.Returns the corresponding edge (a,b) if a and b are adjacent.Collection
<? extends GeneralEdge<? extends T>> getEdges()
Returns the edges of this DirHyperGraph.getNeighbors
(T node) Returns the set of neighbors of the given node.getNodes()
Returns the nodes of this DirHyperGraph.int
Returns the number of nodes in this DirHyperGraph.getParents
(Node node) Returns the set of parents (node connected via an undirected edge or a directed edge where the given node is the child) of the given node.getRestriction
(Collection<T> nodes) Returns copy of this DirHyperGraph consisting only of the given nodes and all corresponding edges.Returns the strongly connected components of this DirHyperGraph.Returns the set of sub DirHyperGraphs of this DirHyperGraph.boolean
Returns "true" iff the DirHyperGraph has a self loop (an edge from a node to itself).boolean
Checks whether this DirHyperGraph only contains weighted edges.iterator()
toString()
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
IGNORE_SELFLOOPS
static final int IGNORE_SELFLOOPSWhen inverting a DirHyperGraph, ignore self loops (don't add and don't remove)- See Also:
-
INVERT_SELFLOOPS
static final int INVERT_SELFLOOPSWhen inverting a DirHyperGraph, deal with self loops like ordinary edges (add if not present and remove if present)- See Also:
-
REMOVE_SELFLOOPS
static final int REMOVE_SELFLOOPSWhen inverting a DirHyperGraph, simple remove self loops, but don't add new ones.- See Also:
-
-
Method Details
-
add
Adds the given node to this DirHyperGraph.- Parameters:
node
- some node.- Returns:
- "true" iff the edge has been added successfully.
-
add
Adds the given edge to this DirHyperGraph. If at least one of the nodes the given edge connects is not in the DirHyperGraph, an illegal argument exception is thrown.- Parameters:
edge
- some edge.- Returns:
- "true" iff the edge has been added successfully.
-
getNodes
Collection<T> getNodes()Returns the nodes of this DirHyperGraph.- Specified by:
getNodes
in interfaceGeneralGraph<T extends Node>
- Returns:
- the nodes of this DirHyperGraph.
-
getNumberOfNodes
int getNumberOfNodes()Returns the number of nodes in this DirHyperGraph.- Returns:
- the number of nodes in this DirHyperGraph.
-
areAdjacent
-
getEdge
Returns the corresponding edge (a,b) if a and b are adjacent. Otherwise it returns null.- Parameters:
a
- some nodeb
- some node- Returns:
- the edge (a,b) or null.
-
getEdges
Collection<? extends GeneralEdge<? extends T>> getEdges()Returns the edges of this DirHyperGraph.- Specified by:
getEdges
in interfaceGeneralGraph<T extends Node>
- Returns:
- the edges of this DirHyperGraph.
-
iterator
-
contains
Returns "true" when this DirHyperGraph contains the given node or edge.- Parameters:
obj
- an object- Returns:
- "true" if this DirHyperGraph contains the given node or edge.
-
getChildren
Returns the set of children (node connected via an undirected edge or a directed edge where the given node is the parent) of the given node.- Parameters:
node
- some node (must be in the DirHyperGraph).- Returns:
- the set of children of the given node.
-
getParents
Returns the set of parents (node connected via an undirected edge or a directed edge where the given node is the child) of the given node.- Parameters:
node
- some node (must be in the DirHyperGraph).- Returns:
- the set of parents of the given node.
-
existsDirectedPath
-
getNeighbors
Returns the set of neighbors of the given node.- Parameters:
node
- some node (must be in the DirHyperGraph).- Returns:
- the set of neighbors of the given node.
-
getAdjacencyMatrix
Matrix getAdjacencyMatrix()Returns the adjacency matrix of this DirHyperGraph (the order of the nodes is the same as returned by "iterator()").- Returns:
- the adjacency matrix of this DirHyperGraph
-
getComplementGraph
Returns the complement DirHyperGraph of this DirHyperGraph, i.e. the DirHyperGraph on the same set of vertices as this DirHyperGraph that connects two vertices v and w with an edge if and only if v and w are not connected in this DirHyperGraph.- Parameters:
selfloops
- Indicates how to deal with selfloops:
IGNORE_SELFLOOPS - ignore self loops (don't add and don't remove)
INVERT_SELFLOOPS - deal with self loops like ordinary edges (add if not present and remove if present)
REMOVE_SELFLOOPS - simple remove self loops, but don't add new ones.- Returns:
- the complement DirHyperGraph of this DirHyperGraph.
-
getStronglyConnectedComponents
Collection<Collection<T>> getStronglyConnectedComponents()Returns the strongly connected components of this DirHyperGraph. A set of nodes is strongly connected, if there is a path from each node to each other. A set of nodes is called strongly connected component if it is strongly connected and maximal with respect to set inclusion.- Returns:
- the strongly connected components of this DirHyperGraph.
-
getSubGraphs
Collection<DirHyperGraph<T>> getSubGraphs()Returns the set of sub DirHyperGraphs of this DirHyperGraph.- Returns:
- the set of sub DirHyperGraphs of this DirHyperGraph.
-
getRestriction
Returns copy of this DirHyperGraph consisting only of the given nodes and all corresponding edges.- Specified by:
getRestriction
in interfaceGeneralGraph<T extends Node>
- Parameters:
nodes
- a set of nodes- Returns:
- a DirHyperGraph.
-
hasSelfLoops
boolean hasSelfLoops()Returns "true" iff the DirHyperGraph has a self loop (an edge from a node to itself).- Returns:
- "true" iff the DirHyperGraph has a self loop (an edge from a node to itself).
-
isWeightedGraph
boolean isWeightedGraph()Checks whether this DirHyperGraph only contains weighted edges.- Returns:
- "true" if all edges are weighted in this DirHyperGraph.
-
toString
-