Class HyperGraph<T extends Node>
java.lang.Object
org.tweetyproject.graphs.HyperGraph<T>
- Type Parameters:
T- A Node
- All Implemented Interfaces:
Iterable<T>,GeneralGraph<T>,Graph<T>
-
Field Summary
Fields inherited from interface org.tweetyproject.graphs.Graph
IGNORE_SELFLOOPS, INVERT_SELFLOOPS, REMOVE_SELFLOOPS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(GeneralEdge<T> edge) Adds the given edge to this graph.booleanadd(HyperDirEdge<T> edge) Add Edge.booleanAdds the given node to this graph.booleanareAdjacent(Node a, Node b) Returns "true" iff the two nodes are connected by a directed edge from a to b or an undirected edge.booleanReturns "true" when this graph contains the given node or edge.booleanexistsDirectedPath(HyperGraph<T> hyperGraph, T node1, T node2) Checks if there is a direct path from node 1 to node 2booleanexistsDirectedPath(T node1, T node2) Checks whether there is a (directed) path from node1 to node2.Returns the adjacency matrix of this graph (the order of the nodes is the same as returned by "iterator()").getChildren(Set<T> node) Return the children of the nodegetChildren(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 graph of this graph, i.e.Returns the set of (simple) connected components of this graph.getDirEdge(Set<T> node1, Node b) Get a directed edge.Returns the corresponding edge (a,b) if a and b are adjacent.getEdges()Returns the edges of this graph.getNeighbors(Node node) Returns the set of neighbors of the given node.getNodes()Returns the nodes of this graph.intReturns the number of edges in this graph.intReturns the number of nodes in this graph.getParents(Node node) returns all parents without taking indivdual attacks into accountgetRestriction(Collection<T> nodes) Returns a copy of this graph that contains only the specified nodes and all corresponding edges between them.Returns the strongly connected components of this graph.Collection<Graph<T>> Returns the set of sub graphs of this graph.Collection<Graph<T>> getSubgraphs(HyperGraph<T> g) Returns the set of sub graphs of the given graph.booleanReturns "true" iff the graph has a self loop (an edge from a node to itself).booleanChecks whether this graph only contains weighted edges.iterator()Return a powerset.toString()Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
HyperGraph
public HyperGraph()constructor
-
-
Method Details
-
add
-
add
Add Edge. Return whether the operation was successful- Parameters:
edge- an edge- Returns:
- whether the operation was successful
-
getNodes
-
getNumberOfNodes
public int getNumberOfNodes()Description copied from interface:GraphReturns the number of nodes in this graph.- Specified by:
getNumberOfNodesin interfaceGraph<T extends Node>- Returns:
- the number of nodes in this graph.
-
getNumberOfEdges
public int getNumberOfEdges()Description copied from interface:GraphReturns the number of edges in this graph.- Specified by:
getNumberOfEdgesin interfaceGraph<T extends Node>- Returns:
- the number of edges in this graph.
-
areAdjacent
Description copied from interface:GraphReturns "true" iff the two nodes are connected by a directed edge from a to b or an undirected edge.- Specified by:
areAdjacentin interfaceGraph<T extends Node>- Parameters:
a- some nodeb- some node- Returns:
- "true" iff the two nodes are connected by a directed edge from a to b or an undirected edge.
-
getEdge
-
getDirEdge
Get a directed edge.- Parameters:
node1- a set of nodes (attacker)b- a node (attacked)- Returns:
- a directed Hyper Edge
-
getEdges
Description copied from interface:GraphReturns the edges of this graph. -
iterator
-
contains
-
getChildren
Description copied from interface:GraphReturns 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.- Specified by:
getChildrenin interfaceGraph<T extends Node>- Parameters:
node- some node (must be in the graph).- Returns:
- the set of children of the given node.
-
getChildren
Return the children of the node- Parameters:
node- a node- Returns:
- the children of the node
-
getParents
returns all parents without taking indivdual attacks into account- Specified by:
getParentsin interfaceGraph<T extends Node>- Parameters:
node- some node (must be in the graph).- Returns:
- the set of parents of the given node.
-
existsDirectedPath
Checks if there is a direct path from node 1 to node 2- Parameters:
hyperGraph- a hypergraphnode1- 1st nodenode2- 2nd node- Returns:
- checks if there is a direct path from node 1 to node 2
-
existsDirectedPath
Description copied from interface:GraphChecks whether there is a (directed) path from node1 to node2.- Specified by:
existsDirectedPathin interfaceGraph<T extends Node>- Parameters:
node1- some node.node2- some node.- Returns:
- "true" if there is a directed path from node1 to node2.
-
getNeighbors
Description copied from interface:GraphReturns the set of neighbors of the given node.- Specified by:
getNeighborsin interfaceGraph<T extends Node>- Parameters:
node- some node (must be in the graph).- Returns:
- the set of neighbors of the given node.
-
getAdjacencyMatrix
-
powerSet
-
getComplementGraph
Description copied from interface:GraphReturns the complement graph of this graph, i.e. the graph on the same set of vertices as this graph that connects two vertices v and w with an edge if and only if v and w are not connected in this graph.- Specified by:
getComplementGraphin interfaceGraph<T extends Node>- 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 graph of this graph.
-
getConnectedComponents
Description copied from interface:GraphReturns the set of (simple) connected components of this graph. A set of nodes is connected, if there is some path (ignoring edge directions) from each node to each other. It is a connected component if it is connected and maximal wrt. set inclusion.- Specified by:
getConnectedComponentsin interfaceGraph<T extends Node>- Returns:
- the connected components of this graph.
-
getStronglyConnectedComponents
Description copied from interface:GraphReturns the strongly connected components of this graph. 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.- Specified by:
getStronglyConnectedComponentsin interfaceGraph<T extends Node>- Returns:
- the strongly connected components of this graph.
-
getSubgraphs
Description copied from interface:GraphReturns the set of sub graphs of this graph.- Specified by:
getSubgraphsin interfaceGraph<T extends Node>- Returns:
- the set of sub graphs of this graph.
-
getSubgraphs
Returns the set of sub graphs of the given graph.- Parameters:
g- a graph- Returns:
- the set of sub graphs of the given graph.
-
getRestriction
Description copied from interface:GeneralGraphReturns a copy of this graph that contains only the specified nodes and all corresponding edges between them.This method generates a subgraph (or restricted graph) from the current graph by including only the given nodes and the edges that connect them. The returned graph is a new instance and does not modify the original graph.
- Specified by:
getRestrictionin interfaceGeneralGraph<T extends Node>- Parameters:
nodes- a collection of nodes to be included in the restricted graph.- Returns:
- a `GeneralGraph` object representing the restricted graph.
-
hasSelfLoops
public boolean hasSelfLoops()Description copied from interface:GraphReturns "true" iff the graph has a self loop (an edge from a node to itself).- Specified by:
hasSelfLoopsin interfaceGraph<T extends Node>- Returns:
- "true" iff the graph has a self loop (an edge from a node to itself).
-
isWeightedGraph
public boolean isWeightedGraph()Description copied from interface:GraphChecks whether this graph only contains weighted edges.- Specified by:
isWeightedGraphin interfaceGraph<T extends Node>- Returns:
- "true" if all edges are weighted in this graph.
-
add
Description copied from interface:GraphAdds the given edge to this graph. If at least one of the nodes the given edge connects is not in the graph, an illegal argument exception is thrown. -
toString
-