Class FastTree<U>
java.lang.Object
es.uam.eps.ir.relison.graph.fast.AbstractFastGraph<U>
es.uam.eps.ir.relison.graph.tree.fast.FastTree<U>
- Type Parameters:
U- Type of the nodes of the tree
- All Implemented Interfaces:
DirectedGraph<U>,FastGraph<U>,Graph<U>,Tree<U>,ReducedIndex<U>,java.io.Serializable
- Direct Known Subclasses:
FastUnweightedTree,FastWeightedTree
public abstract class FastTree<U> extends AbstractFastGraph<U> implements Tree<U>
Fast implementation of the tree.
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
Constructors Constructor Description FastTree(DirectedEdges edges)Constructor. -
Method Summary
Modifier and Type Method Description booleanaddChild(U parent, U child, double weight, int type)Adds a child to a given node.booleanaddEdge(U nodeA, U nodeB, double weight, int type, boolean insertNodes)Adds a weighted edge to the graph.booleanaddNode(U node)Adds a new node to the graph.booleanaddRoot(U root)Adds a root to the tree.Index<U>getAdjacencyMatrixMap()For an adjacency matrix, obtains the mapping between indexes and nodes.java.util.stream.Stream<U>getChildren(U u)Obtains the direct children of a node.longgetChildrenCount(U u)Gets the number of children of a node.java.util.stream.Stream<Weight<U,java.lang.Double>>getChildrenWeights(U u)Obtains the weights of the children of a node.java.util.stream.Stream<U>getLeaves()Obtain the leaves of the tree.java.util.stream.Stream<U>getLeaves(U u)Obtains the leaves of a tree that come from a certain nodejava.util.stream.Stream<U>getLevel(int level)Obtains all the nodes in a given level of the tree.java.util.Map<java.lang.Integer,java.util.Set<U>>getLevels()Obtains all the nodes on each level.UgetParent(U u)Obtains the parent of a node.doublegetParentWeight(U u)Obtains the weight of the edge between a node and its parentUgetRoot()Obtains the root of the graph.booleanisAscendant(U parent, U child)Checks if a node is ascendant of another onebooleanisLeaf(U u)Indicates if the node is a leaf or not.booleanisParent(U parent, U child)Checks if a node is the parent of another one.booleanisRoot(U u)Indicates if the node is the root node or not.Methods inherited from class es.uam.eps.ir.relison.graph.fast.AbstractFastGraph
addEdge, complement, containsEdge, containsEdge, containsVertex, getAdjacentEdgesCount, getAdjacentMutualNodesTypes, getAdjacentMutualNodesWeights, getAdjacentNodes, getAdjacentNodesTypes, getAdjacentNodesWeights, getAllNodes, getAllNodesIds, getEdgeCount, getEdgeType, getEdgeWeight, getEdgeWeight, getIncidentEdgesCount, getIncidentMutualNodesTypes, getIncidentMutualNodesWeights, getIncidentNodes, getIncidentNodesTypes, getIncidentNodesWeights, getIndex, getIsolatedNodeIds, getIsolatedNodes, getMutualEdgesCount, getMutualNodes, getMutualNodesTypes, getMutualNodesWeights, getNeighborhood, getNeighborhoodTypes, getNeighborhoodWeights, getNeighbourhood, getNeighbourNodes, getNeighbourNodesTypes, getNeighbourNodesWeights, getNodesIdsWithEdges, getNodesWithAdjacentNeighbors, getNodesWithIncidentNeighbors, getNodesWithMutualNeighbors, getNodesWithNeighbors, getNodesWithNeighbors, getVertexCount, hasAdjacentNeighbors, hasIncidentNeighbors, hasMutualNeighbors, hasNeighbors, idx2object, object2idx, removeEdge, removeNode, updateEdgeType, updateEdgeWeight, updateEdgeWeightMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface es.uam.eps.ir.relison.graph.DirectedGraph
degree, degree, getNeighbourEdgesCount, getNeighbourhood, getNeighbourhoodSize, getNeighbourhoodTypes, getNeighbourhoodWeights, getSinks, getSources, inDegree, isDirected, mutualDegree, outDegreeMethods inherited from interface es.uam.eps.ir.relison.graph.Graph
addEdge, addEdge, addEdge, addEdge, addEdge, complement, containsEdge, containsVertex, getAdjacencyMatrix, getAdjacentEdgesCount, getAdjacentMutualNodesTypes, getAdjacentMutualNodesWeights, getAdjacentNodes, getAdjacentNodesCount, getAdjacentNodesTypes, getAdjacentNodesWeights, getAllNodes, getEdgeCount, getEdgeType, getEdgeWeight, getIncidentEdgesCount, getIncidentMutualNodesTypes, getIncidentMutualNodesWeights, getIncidentNodes, getIncidentNodesCount, getIncidentNodesTypes, getIncidentNodesWeights, getIsolatedNodes, getMutualEdgesCount, getMutualNodes, getMutualNodesCount, getMutualNodesTypes, getMutualNodesWeights, getNeighbourNodes, getNeighbourNodesCount, getNeighbourNodesTypes, getNeighbourNodesWeights, getNodesWithAdjacentNeighbors, getNodesWithIncidentNeighbors, getNodesWithMutualNeighbors, getNodesWithNeighbors, getNodesWithNeighbors, getVertexCount, hasAdjacentNeighbors, hasIncidentNeighbors, hasMutualNeighbors, hasNeighbors, hasNeighbors, isMultigraph, isMutual, isWeighted, removeEdge, removeNode, updateEdgeType, updateEdgeWeightMethods inherited from interface es.uam.eps.ir.relison.graph.tree.Tree
addChild, addChild, getDescendants, isChild, isDescendant
-
Constructor Details
-
FastTree
Constructor.- Parameters:
edges- The edges of the tree.
-
-
Method Details
-
getRoot
Description copied from interface:TreeObtains the root of the graph. -
getLeaves
Description copied from interface:TreeObtain the leaves of the tree. -
getLeaves
Description copied from interface:TreeObtains the leaves of a tree that come from a certain node -
getLevel
Description copied from interface:TreeObtains all the nodes in a given level of the tree. Root equal to 0. -
getLevels
Description copied from interface:TreeObtains all the nodes on each level. -
getChildren
Description copied from interface:TreeObtains the direct children of a node.- Specified by:
getChildrenin interfaceTree<U>- Parameters:
u- the parent node- Returns:
- A stream containing the children of a node. If it is a leaf, an empty stream is returned. If the node does not exist, null.
-
getChildrenCount
Description copied from interface:TreeGets the number of children of a node.- Specified by:
getChildrenCountin interfaceTree<U>- Parameters:
u- the node.- Returns:
- the number of children, -1 if the node does not exist.
-
getParent
Description copied from interface:TreeObtains the parent of a node. -
isLeaf
Description copied from interface:TreeIndicates if the node is a leaf or not. -
isRoot
Description copied from interface:TreeIndicates if the node is the root node or not. -
addRoot
Description copied from interface:TreeAdds a root to the tree. -
addChild
Description copied from interface:TreeAdds a child to a given node. -
isParent
Description copied from interface:TreeChecks if a node is the parent of another one. -
isAscendant
Description copied from interface:TreeChecks if a node is ascendant of another one- Specified by:
isAscendantin interfaceTree<U>- Parameters:
parent- the first node (the possible ascendant)child- the second node (the possible descendant)- Returns:
- true if the second node descends from the first, false if not.
-
addNode
Description copied from interface:GraphAdds a new node to the graph. -
addEdge
Description copied from interface:GraphAdds a weighted edge to the graph.- Specified by:
addEdgein interfaceGraph<U>- Specified by:
addEdgein interfaceTree<U>- Overrides:
addEdgein classAbstractFastGraph<U>- Parameters:
nodeA- The incident node.nodeB- The adjacent node.weight- The weight.type- The edge type.insertNodes- If true, nodes will be inserted if they do not exist. If false, the edge will only be added if both nodes are inserted.- Returns:
- if the edge is correctly added, false if not.
-
getChildrenWeights
Description copied from interface:TreeObtains the weights of the children of a node.- Specified by:
getChildrenWeightsin interfaceTree<U>- Parameters:
u- The parent node.- Returns:
- A stream containing the children of the node if it exists, null if not.
-
getParentWeight
Description copied from interface:TreeObtains the weight of the edge between a node and its parent- Specified by:
getParentWeightin interfaceTree<U>- Parameters:
u- The child node- Returns:
- The weight if the node exists and it is not the root, NaN otherwise.
-
getAdjacencyMatrixMap
Description copied from interface:GraphFor an adjacency matrix, obtains the mapping between indexes and nodes.- Specified by:
getAdjacencyMatrixMapin interfaceGraph<U>- Overrides:
getAdjacencyMatrixMapin classAbstractFastGraph<U>- Returns:
- the mapping between indexes and nodes.
-