Class GenericDirectedGraphGRPHimpl
- java.lang.Object
-
- grph.Grph
-
- grph.in_memory.InMemoryGrph
-
- edu.upf.taln.dri.lib.model.graph.generic.GenericDirectedGraphGRPHimpl
-
- All Implemented Interfaces:
GenericDirectedGraph
,grph.GrphPrimitives
,Serializable
,Cloneable
public class GenericDirectedGraphGRPHimpl extends grph.in_memory.InMemoryGrph implements GenericDirectedGraph
IMPORTANT: Never instantiate directly this class!
Generic graph implementation.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class grph.Grph
adjacencyMatrixAlgo, allClusteringCoefficientsAlgorithm, avgClusteringCoefficientAlgorithm, avgDegreeAlgorithm, bfsAlgorithm, bipartiteAlgorithm, branchingMinimumVertexCoverAlgorithm, bruteForceMinimumVertexCoverAlgorithm, centerAlgorithm, chordalAlgo, COMPILATION_DIRECTORY, complementAlgorithm, completenessAlgorithm, connectedComponentsAlg, connectednessAlgorithm, densityAlgorithm, diameterAlgorithm, FominGrandoniKratschMaximumindependentSetAlgorithm, girthAlgorithm, HOSTS, inacessibleVertices, incidenceMatrixAlgo, inNeighborsAlgorithm, inOutNeighborsAlgorithm, irreflexiveAlgorithm, isCyclicAlgorithm, isolatedVerticesAlgorithm, lineGraphAlg, logger, LPMaximumindependentSetAlgorithm, LPMaxMatchingAlgorithm, LPMinVertexCoverAlgorithm, maxInEdgeDegreeAlgorithm, maxInVertexDegreeAlgorithm, maxOutEdgeDegreeAlgorithm, maxOutVertexDegreeAlgorithm, minInEdgeDegreeAlgorithm, minInVertexDegreeAlgorithm, minOutEdgeDegreeAlgorithm, minOutVertexDegreeAlgorithm, multigraphnessAlgorithm, NiedermeierMinimumVertexCoverAlgorithm, outNeighborsAlgorithm, radiusAlgorithm, reflexivityAlgorithm, regularityAlgorithm, simplenessAlgorithm, tarjanSCC, topologicalSortingAlg, treenessAlgorithm, trianglesAlgorithm, twoSweepDiameterAlg, unweightedDistanceMatrixAlgorithm, unweightedPredecessorMatrixAlgorithm, useCache, vertexAdjacenciesAsIDSetsAlgorithm, vertexListAlgorithm
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Integer
addEdge(Integer from, Integer to, String edgeName)
Add a new edge (directed)boolean
addEdgeFeature(Integer edgeId, String featureName, Object featureValue)
Add the named feature to the edge.Integer
addNode(Integer nodeId, String nodeName)
Add a new nodeboolean
addNodeFeature(Integer nodeId, String featureName, Object featureValue)
Add the named feature to the node.boolean
changeEdgeName(Integer edgeId, String edgeName)
Change the name of an existing edge - the new name should not be empty or nullboolean
changeNodeName(Integer nodeId, String nodeName)
Set a new name of an existing nodeMap<Integer,org.apache.commons.lang3.tuple.Pair<Integer,Integer>>
getAllEdgeConnections()
Map with id (key) of edges and pair of id of the nodes each vertex connectsSet<Integer>
getChildrenNodes(Integer nodeId)
Get the ids of all the children of a nodeInteger
getChildrenNodesCount(Integer nodeId)
Get the number of children of the nodeInteger
getEdgeCount()
Number of edgesMap<String,Object>
getEdgeFeatures(Integer edgeId)
Get the named edge feature mapString
getEdgeName(Integer edgeId)
Name of graph edgesMap<Integer,String>
getEdgeNames(Integer edgeId)
Map with id (key) and name of graph edgesSet<Integer>
getEdgesByKindSourceAndDestination(Integer sourceId, Integer destinationId, String name)
Get edges by source node id / destination node id / name At least on of source node Id / destination node Id / name has not to be blank / empty.Set<Integer>
getEdgesByName(String name)
Get the set of edges with with a specific nameMap<Integer,org.apache.commons.lang3.tuple.Pair<Integer,Integer>>
getIncidentEdges(Integer nodeId)
Get the set of edges entering in the nodeInteger
getNodeCount()
Number of nodesMap<String,Object>
getNodeFeatures(Integer nodeId)
Get the named node feature mapString
getNodeName(Integer nodeId)
Name of graph nodeMap<Integer,String>
getNodeNames(Integer nodeId)
Map with id (key) and name of graph nodesSet<Integer>
getNodesByName(String name)
Get the set of nodes with with a specific nameMap<Integer,org.apache.commons.lang3.tuple.Pair<Integer,Integer>>
getOutgoingEdges(Integer nodeId)
Get the set of edges going out from the nodeSet<Integer>
getParentNodes(Integer nodeId)
Get the ids of all the parents of a nodeInteger
getParentNodesCount(Integer nodeId)
Get the number of parents of the nodeSet<Integer>
getRoots()
Get the ids of root nodesString
graphAsString(GraphToStringENUM outputType)
Serialize the graph contents as a stringboolean
removeEdge(Integer edgeId)
Remove an edgeint
removeEdgesByNameSourceAndDestination(Integer sourceId, Integer destinationId, String name)
Remove all edges with a specific source node id / destination node id / name At least one of source node Id / destination node Id / name has not to be blank / empty.boolean
removeNode(Integer nodeId)
Remove a node together with all its incident edges-
Methods inherited from class grph.in_memory.InMemoryGrph
addDirectedHyperEdge, addDirectedSimpleEdge, addToDirectedHyperEdgeHead, addToDirectedHyperEdgeTail, addToUndirectedHyperEdge, addUndirectedHyperEdge, addUndirectedSimpleEdge, addVertex, containsEdge, containsVertex, getDirectedHyperEdgeHead, getDirectedHyperEdgeTail, getDirectedSimpleEdgeHead, getDirectedSimpleEdgeTail, getEdges, getInOnlyElements, getInOutOnlyElements, getNavigation, getNextEdgeAvailable, getNextVertexAvailable, getNumberOfDirectedHyperEdges, getNumberOfDirectedSimpleEdges, getNumberOfUndirectedHyperEdges, getNumberOfUndirectedSimpleEdges, getOneVertex, getOutOnlyElements, getTheOtherVertex, getUndirectedHyperEdgeVertices, getVertices, isDirectedHyperEdge, isDirectedSimpleEdge, isUndirectedHyperEdge, isUndirectedSimpleEdge, main, removeEdge, removeEdge, removeFromDirectedHyperEdgeHead, removeFromDirectedHyperEdgeTail, removeFromHyperEdge, removeVertex, storeEdges
-
Methods inherited from class grph.Grph
addDirectedSimpleEdge, addGraph, addHyperEdge, addNVertices, addSimpleEdge, addSimpleEdge, addUndirectedSimpleEdge, addVertex, addVertices, areEdgesAdjacent, areVerticesAdjacent, bfs, bfs, bfsList, chain, clear, clearCache, clique, clique, clone, computeMaxFlow, connectToKClosestNeighbors, contains, containsAPath, contractEdge, contractVertices, contractVertices, createSwingRenderer, dgrid, disconnect, disconnectVertex, display, displayGraphstream_0_4_2, displayImg, displayReport, displaySVGSalamander, dring, ensureNVertices, equals, equals, findAlgorithm, findPropertyByName, fromCaidaMap, fromGraphML, fromGraphML, fromGrphBinary, fromGrphText, fromGrphTextFile, getAdjacencyMatrix, getAllCycles, getAllInEdgeDegrees, getAllOutEdgeDegrees, getAllPaths, getAverageClusteringCoefficient, getAverageDegree, getAverageDegree, getBipartiteSubgraphInducedByVertices, getCache, getCenter, getCircleStar, getCliques, getClusteringCoefficient, getClusteringCoefficient, getClusteringCoefficientDistribution, getComplement, getConnectedComponentContaining, getConnectedComponents, getCutEdges, getCutSize, getDefaultNumberOfThreads, getDegreeDistribution, getDensity, getDescription, getDiameter, getDifference, getDistanceMatrix, getEccentricity, getEccentricity, getEdgeColorProperty, getEdgeDegree, getEdgeLabelProperty, getEdgeNature, getEdgePairs, getEdgesAdjacentToEdge, getEdgesConnecting, getEdgesIncidentTo, getEdgeStyleProperty, getEdgeWidthProperty, getFartestVertex, getFartestVertex, getFringes, getGirth, getGpmetisPartitionning, getGpmetisPartitionning, getInaccessibleVertices, getIncidenceMatrix, getInducedSubgraphIsomorphism, getInEdgeDegree, getInEdges, getInElements, getInNeighborhoods, getInNeighbors, getInNeighbours, getInOnlyEdges, getInOutOnlyEdges, getInVertexDegree, getIsolatedVertices, getKClosestNeighbors, getKShortestPaths, getLargestConnectedComponent, getLineGraph, getLineGraph, getLocalClusteringCoefficients, getLoops, getMaximumClique, getMaximumIndependentSet, getMaximumIndependentSet, getMaximumMatching, getMaxInEdgeDegrees, getMaxInVertexDegrees, getMaxOutEdgeDegrees, getMaxOutVertexDegrees, getMinimumVertexCover, getMinimumVertexCover, getMinInEdgeDegrees, getMinInVertexDegrees, getMinOutEdgeDegrees, getMinOutVertexDegrees, getNeighborhoods, getNeighbors, getNeighborsAtMaxDistance, getNeighbours, getNeighbours, getNeighbours, getNeighboursAtMostKHops, getNumberOfDirectedEdges, getNumberOfEdges, getNumberOfHyperEdges, getNumberOfSimpleEdges, getNumberOfTriangles, getNumberOfUndirectedEdges, getNumberOfVertices, getOppositeEdges, getOrder, getOutEdgeDegree, getOutEdges, getOutNeighborhoods, getOutNeighbors, getOutOnlyEdges, getOutVertexDegree, getPageRanking, getPartialSubgraphIsomorphism, getProperties, getRadius, getShortestCycle, getShortestPath, getShortestPath, getSimplicialVertices, getSinks, getSize, getSomeEdgeConnecting, getSources, getSpanningTree, getStronglyConnectedComponents, getSubgraphInducedByEdges, getSubgraphInducedByVertices, getTopologyListeners, getTwoSweepBFSDiameterApproximatedDiameter, getVersion, getVertexColorProperty, getVertexDegree, getVertexDegree, getVertexLabelProperty, getVertexShapeProperty, getVertexSizeProperty, getVerticesAccessibleThrough, getVerticesAccessibleThrough, getVerticesIncidentToEdge, getVerticesOfDegree, getVerticesOfDegree, getVerticesOfDegreeAtLeast, glp, grid, grid, hasCycles, hasLoop, hasLoops, hasMultipleEdges, highlight, highlight, highlight, highlight, highlightEdges, highlightEdges, highlightVertex, highlightVertices, highlightVertices, highlightVertices, highlightVertices, isAntigraph, isBipartite, isChordal, isClique, isComplete, isConnected, isCut, isCut, isCyclic, isDirected, isDirectedSimpleEdge, isDirectedSimpleGraph, isDominatingSet, isHyperEdge, isHypergraph, isIndependentSet, isIrreflexive, isIsomorphicTo, isLeaf, isLoop, isMatching, isMixed, isNull, isReflexive, isRegular, isSimple, isSimpleEdge, isSimplicial, isSink, isSource, isStronglyConnected, isTree, isTrivial, isUndirectedSimpleEdge, isUndirectedSimpleGraph, isVertexCover, listCachingGraphAlgorithms, loadOnlineGrph, merge, performRandomTopologicalChange, postOnTheWeb, prune, removeEdges, removeVertices, removeVertices, removeVertices, report, revertEdge, ring, ring, ring, rnws, rnws, search, setEdgesColor, setEdgesLabel, setEdgesStyle, setEdgesWidth, setVerticesColor, setVerticesLabel, setVerticesShape, setVerticesSize, sortTopologically, sortVerticesByDegree, stepMonitor, toDot, toGraphML, toGraphStream_0_4_2_AWTComponent, toGraphviz, toGraphviz, toGrphBinary, toGrphText, toString, toString_elements, toUndirectedGraph, undirectionalizeEdge
-
-
-
-
Method Detail
-
addNode
public Integer addNode(Integer nodeId, String nodeName)
Description copied from interface:GenericDirectedGraph
Add a new node- Specified by:
addNode
in interfaceGenericDirectedGraph
- Parameters:
nodeId
- if null the first available id will be chosen for this node (the ID of the node is unambiguous graph-wide)nodeName
- each node should have a name (leaving null or empty will not create the node)- Returns:
- the id of the new node. If null the new node has not been added
-
changeNodeName
public boolean changeNodeName(Integer nodeId, String nodeName)
Description copied from interface:GenericDirectedGraph
Set a new name of an existing node- Specified by:
changeNodeName
in interfaceGenericDirectedGraph
nodeName
- not null or empty- Returns:
-
removeNode
public boolean removeNode(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Remove a node together with all its incident edges- Specified by:
removeNode
in interfaceGenericDirectedGraph
- Returns:
-
addEdge
public Integer addEdge(Integer from, Integer to, String edgeName)
Description copied from interface:GenericDirectedGraph
Add a new edge (directed)- Specified by:
addEdge
in interfaceGenericDirectedGraph
- Parameters:
from
- the id of the starting nodeto
- the id of the ending nodeedgeName
- each node should have a name (leaving null or empty will not create the node)- Returns:
-
changeEdgeName
public boolean changeEdgeName(Integer edgeId, String edgeName)
Description copied from interface:GenericDirectedGraph
Change the name of an existing edge - the new name should not be empty or null- Specified by:
changeEdgeName
in interfaceGenericDirectedGraph
- Returns:
-
removeEdge
public boolean removeEdge(Integer edgeId)
Description copied from interface:GenericDirectedGraph
Remove an edge- Specified by:
removeEdge
in interfaceGenericDirectedGraph
- Returns:
-
addNodeFeature
public boolean addNodeFeature(Integer nodeId, String featureName, Object featureValue)
Description copied from interface:GenericDirectedGraph
Add the named feature to the node. If a node feature with this name is present, the feature is overwritten.- Specified by:
addNodeFeature
in interfaceGenericDirectedGraph
- Parameters:
nodeId
- the id of the nodefeatureName
- can't be null or empty- Returns:
- true if the feature is added
-
addEdgeFeature
public boolean addEdgeFeature(Integer edgeId, String featureName, Object featureValue)
Description copied from interface:GenericDirectedGraph
Add the named feature to the edge. If an edge feature with this name is present, the feature is overwritten.- Specified by:
addEdgeFeature
in interfaceGenericDirectedGraph
featureName
- can't be null or empty- Returns:
- true if the feature is added
-
removeEdgesByNameSourceAndDestination
public int removeEdgesByNameSourceAndDestination(Integer sourceId, Integer destinationId, String name)
Description copied from interface:GenericDirectedGraph
Remove all edges with a specific source node id / destination node id / name At least one of source node Id / destination node Id / name has not to be blank / empty. (AND OF source id, destination id and kind checks)- Specified by:
removeEdgesByNameSourceAndDestination
in interfaceGenericDirectedGraph
- Parameters:
sourceId
- if not blank only the edges with this source id are removeddestinationId
- if not blank only the edges with this destination id are removed- Returns:
- number of edges removed
-
getNodesByName
public Set<Integer> getNodesByName(String name)
Description copied from interface:GenericDirectedGraph
Get the set of nodes with with a specific name- Specified by:
getNodesByName
in interfaceGenericDirectedGraph
- Returns:
-
getNodeNames
public Map<Integer,String> getNodeNames(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Map with id (key) and name of graph nodes- Specified by:
getNodeNames
in interfaceGenericDirectedGraph
- Parameters:
nodeId
- If null all the node names are retrieved. Otherwise only the name of the node with the specified id, if present.- Returns:
-
getNodeName
public String getNodeName(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Name of graph node- Specified by:
getNodeName
in interfaceGenericDirectedGraph
- Returns:
-
getEdgesByName
public Set<Integer> getEdgesByName(String name)
Description copied from interface:GenericDirectedGraph
Get the set of edges with with a specific name- Specified by:
getEdgesByName
in interfaceGenericDirectedGraph
- Returns:
-
getEdgeNames
public Map<Integer,String> getEdgeNames(Integer edgeId)
Description copied from interface:GenericDirectedGraph
Map with id (key) and name of graph edges- Specified by:
getEdgeNames
in interfaceGenericDirectedGraph
- Parameters:
edgeId
- If null all the edge names are retrieved. Otherwise only the name of the edge with the specified id, if present.- Returns:
-
getEdgeName
public String getEdgeName(Integer edgeId)
Description copied from interface:GenericDirectedGraph
Name of graph edges- Specified by:
getEdgeName
in interfaceGenericDirectedGraph
- Returns:
-
getNodeCount
public Integer getNodeCount()
Description copied from interface:GenericDirectedGraph
Number of nodes- Specified by:
getNodeCount
in interfaceGenericDirectedGraph
- Returns:
-
getEdgeCount
public Integer getEdgeCount()
Description copied from interface:GenericDirectedGraph
Number of edges- Specified by:
getEdgeCount
in interfaceGenericDirectedGraph
- Returns:
-
getChildrenNodes
public Set<Integer> getChildrenNodes(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Get the ids of all the children of a node- Specified by:
getChildrenNodes
in interfaceGenericDirectedGraph
- Returns:
-
getChildrenNodesCount
public Integer getChildrenNodesCount(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Get the number of children of the node- Specified by:
getChildrenNodesCount
in interfaceGenericDirectedGraph
- Returns:
-
getParentNodes
public Set<Integer> getParentNodes(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Get the ids of all the parents of a node- Specified by:
getParentNodes
in interfaceGenericDirectedGraph
- Returns:
-
getParentNodesCount
public Integer getParentNodesCount(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Get the number of parents of the node- Specified by:
getParentNodesCount
in interfaceGenericDirectedGraph
- Returns:
-
getRoots
public Set<Integer> getRoots()
Description copied from interface:GenericDirectedGraph
Get the ids of root nodes- Specified by:
getRoots
in interfaceGenericDirectedGraph
- Returns:
-
getIncidentEdges
public Map<Integer,org.apache.commons.lang3.tuple.Pair<Integer,Integer>> getIncidentEdges(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Get the set of edges entering in the node- Specified by:
getIncidentEdges
in interfaceGenericDirectedGraph
- Returns:
-
getOutgoingEdges
public Map<Integer,org.apache.commons.lang3.tuple.Pair<Integer,Integer>> getOutgoingEdges(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Get the set of edges going out from the node- Specified by:
getOutgoingEdges
in interfaceGenericDirectedGraph
- Returns:
-
getAllEdgeConnections
public Map<Integer,org.apache.commons.lang3.tuple.Pair<Integer,Integer>> getAllEdgeConnections()
Description copied from interface:GenericDirectedGraph
Map with id (key) of edges and pair of id of the nodes each vertex connects- Specified by:
getAllEdgeConnections
in interfaceGenericDirectedGraph
- Returns:
-
getNodeFeatures
public Map<String,Object> getNodeFeatures(Integer nodeId)
Description copied from interface:GenericDirectedGraph
Get the named node feature map- Specified by:
getNodeFeatures
in interfaceGenericDirectedGraph
- Returns:
-
getEdgeFeatures
public Map<String,Object> getEdgeFeatures(Integer edgeId)
Description copied from interface:GenericDirectedGraph
Get the named edge feature map- Specified by:
getEdgeFeatures
in interfaceGenericDirectedGraph
- Returns:
-
getEdgesByKindSourceAndDestination
public Set<Integer> getEdgesByKindSourceAndDestination(Integer sourceId, Integer destinationId, String name)
Description copied from interface:GenericDirectedGraph
Get edges by source node id / destination node id / name At least on of source node Id / destination node Id / name has not to be blank / empty. (AND OF source node id, destination node id and name checks)- Specified by:
getEdgesByKindSourceAndDestination
in interfaceGenericDirectedGraph
- Returns:
- filtered edges list
-
graphAsString
public String graphAsString(GraphToStringENUM outputType)
Description copied from interface:GenericDirectedGraph
Serialize the graph contents as a string- Specified by:
graphAsString
in interfaceGenericDirectedGraph
- Returns:
-
-