NodeNameType
- The type for node names in the input graphpublic class GraphMetrics<NodeNameType>
extends java.lang.Object
Constructor and Description |
---|
GraphMetrics(DirectedNodeEdgeGraph<NodeNameType> graph)
Initialize this as an empty metrics class surrounding the input graph.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all cached metrics for the originally input graph.
|
int[] |
computeAllDistancesForNode(int nodeId)
Helper which computes Dijkstra's Algorithm for the input node and returns
all of the distances to all other nodes from this node.
|
int |
degree(int nodeId)
Return the degree for the input nodeId.
|
int |
degree(NodeNameType nodeName)
Return the degree for the input node.
|
double |
degreeAssortativity()
Returns the whole-graph degree assortativity score.
|
int |
getDiameter()
Returns the diameter for this graph.
|
double |
getEdgeJaccardSimilarity(int edgeId)
Returns the Jaccard Similarity for each edge of the graph.
|
java.util.Set<java.lang.Integer> |
getEdgeTriangleOtherEndpointIds(int edgeId)
Returns the ids for the third nodes for all triangles this edge
participates in.
|
java.util.Set<NodeNameType> |
getEdgeTriangleOtherEndpointNames(int edgeId)
Returns the names for the third nodes for all triangles this edge
participates in.
|
java.util.Set<Pair<java.lang.Integer,java.lang.Integer>> |
getNodeTriangleEndpointIds(int nodeId)
Returns the other two endpoint ids for all triangles the node
participates in.
|
java.util.Set<Pair<java.lang.Integer,java.lang.Integer>> |
getNodeTriangleEndpointIds(NodeNameType nodeName)
Returns the other two endpoint ids for all triangles the node
participates in.
|
java.util.Set<Pair<NodeNameType,NodeNameType>> |
getNodeTriangleEndpoints(int nodeId)
Returns the other two endpoint names for all triangles the node
participates in.
|
java.util.Set<Pair<NodeNameType,NodeNameType>> |
getNodeTriangleEndpoints(NodeNameType nodeName)
Returns the other two endpoint names for all triangles the node
participates in.
|
double |
getPerEdgeTriangleDensity(int edgeId)
Returns the per-edge triangle density for the input edge
|
double |
getPerNodeBetweennessCentrality(NodeNameType node)
Returns the per-node betweenness centrality for the input node
|
double |
getPerNodeBetweennessCentralityById(int nodeId)
Returns the per-node betweenness centrality for the input node
|
int |
getPerNodeEccentricity(NodeNameType node)
Returns the per-node eccentricity for the input node
|
int |
getPerNodeEccentricityById(int nodeId)
Returns the per-node eccentricity for the input node
|
int |
getRadius()
Returns the radius for this graph.
|
void |
initializeDegreeAssortativity()
Initialize the degree assortativity for the whole graph.
|
void |
initializeEdgeTriangles()
Initializes the datastructure for all triangles that all nodes and edges
participate in.
|
void |
initializeNodeDegrees()
Initializes the unweighted degree values for all nodes in the graph.
|
void |
initializeNodeNeighbors()
Initializes the neighbors (undirected) for all nodes in the graph at
once.
|
void |
initializeNodeSuccessors()
Initializes the node successors (directed version of neighbors).
|
void |
initializeNodeTriangles()
Initializes the datastructure for all triangles that all nodes and edges
participate in.
|
void |
initializePerEdgeJaccardSimilarity()
Initializes the Jaccard similarity for each edge in the graph.
|
void |
initializePerEdgeTriangleDensity()
Initializes the per-edge triangle density.
|
void |
initializePerNodeBetweennessCentrality()
Initializes the per-node eccentricity.
|
void |
initializePerNodeEccentricity()
Initializes the per-node eccentricity.
|
boolean |
isWcc()
Returns true if the graph is a single weakly connected component (WCC),
else false.
|
java.util.Set<java.lang.Integer> |
neighborIds(int nodeId)
Returns the ids of all neighbors for the input node id.
|
java.util.Set<java.lang.Integer> |
neighborIds(NodeNameType nodeName)
Returns the ids of all neighbors for the input node name.
|
java.util.Set<NodeNameType> |
neighbors(int nodeId)
Returns the names of all neighbors for the input node id.
|
java.util.Set<NodeNameType> |
neighbors(NodeNameType nodeName)
Returns the names of all neighbors for the input node name.
|
int |
numEdges()
Returns the number of edges in the graph.
|
int |
numEdgeTriangles(int edgeId)
Returns the number of triangles the input edge participates in.
|
int |
numNeighbors(int nodeId)
Returns the number of neighbors for the input node id.
|
int |
numNeighbors(NodeNameType nodeName)
Returns the number of neighbors for the input node name.
|
int |
numNodes()
Returns the number of nodes in the graph.
|
int |
numNodeTriangles(int nodeId)
Returns the number of triangles the node participates in.
|
int |
numNodeTriangles(NodeNameType nodeName)
Returns the number of triangles the node participates in.
|
int |
numSuccessors(int nodeId)
Returns the number of direct successors for the input node.
|
int |
numSuccessors(NodeNameType nodeName)
Returns the number of direct successors for the input node.
|
java.util.Set<java.lang.Integer> |
successorIds(int nodeId)
Returns the id for all direct successors for the input node.
|
java.util.Set<java.lang.Integer> |
successorIds(NodeNameType nodeName)
Returns the ids of the direct successors for the input node.
|
java.util.Set<NodeNameType> |
successors(int nodeId)
Returns the node names for all direct successors to the input node.
|
java.util.Set<NodeNameType> |
successors(NodeNameType nodeName)
Returs the node names for all direct successors to the input node.
|
public GraphMetrics(DirectedNodeEdgeGraph<NodeNameType> graph)
graph
- The graph whose metrics will be computed and returned by
thispublic void clear()
public int numNodes()
public int numEdges()
public void initializeNodeDegrees()
public int degree(int nodeId)
nodeId
- The node id of the node whose degree is wantedpublic int degree(NodeNameType nodeName)
nodeName
- The name of the node whose degree is wantedpublic void initializeNodeNeighbors()
public int numNeighbors(int nodeId)
nodeId
- The node whose number of neighbors is wantedpublic int numNeighbors(NodeNameType nodeName)
nodeName
- The node whose number of neighbors is wantedpublic java.util.Set<java.lang.Integer> neighborIds(int nodeId)
nodeId
- The ndoe whose neighbor ids are wantedpublic java.util.Set<java.lang.Integer> neighborIds(NodeNameType nodeName)
nodeName
- The node whose neighbor ids are wantedpublic java.util.Set<NodeNameType> neighbors(int nodeId)
nodeId
- The node whose neighbor names are wantedpublic java.util.Set<NodeNameType> neighbors(NodeNameType nodeName)
nodeName
- The node whose neighbor names are wantedpublic void initializeNodeSuccessors()
public int numSuccessors(int nodeId)
nodeId
- The node whose successor count is desiredpublic int numSuccessors(NodeNameType nodeName)
nodeName
- The node whose successor count is desiredpublic java.util.Set<java.lang.Integer> successorIds(int nodeId)
nodeId
- The node whose successors' ids is desiredpublic java.util.Set<java.lang.Integer> successorIds(NodeNameType nodeName)
nodeName
- The node whose successors' ids is desiredpublic java.util.Set<NodeNameType> successors(int nodeId)
nodeId
- The node whose successors' names is desiredpublic java.util.Set<NodeNameType> successors(NodeNameType nodeName)
nodeName
- The node whose successors' names is desired@PublicationReference(author="Siddharth Suri and Sergei Vassilvitskii", title="Counting Triangles and the Curse of the Last Reducer", year=2011, publication="Proceedings of the World Wide Web Conference (WWW)", type=Conference) public void initializeNodeTriangles()
public int numNodeTriangles(int nodeId)
nodeId
- The node whose number of triangles is desiredpublic int numNodeTriangles(NodeNameType nodeName)
nodeName
- The node whose number of triangles is desiredpublic java.util.Set<Pair<java.lang.Integer,java.lang.Integer>> getNodeTriangleEndpointIds(int nodeId)
nodeId
- The node whose triangles are requestedpublic java.util.Set<Pair<java.lang.Integer,java.lang.Integer>> getNodeTriangleEndpointIds(NodeNameType nodeName)
nodeName
- The node whose triangles are requestedpublic java.util.Set<Pair<NodeNameType,NodeNameType>> getNodeTriangleEndpoints(int nodeId)
nodeId
- The node whose triangles are requestedpublic java.util.Set<Pair<NodeNameType,NodeNameType>> getNodeTriangleEndpoints(NodeNameType nodeName)
nodeName
- The node whose triangles are requested@PublicationReference(author="M. E. J. Newman", title="Assortative mixing in networks", type=Journal, year=2002, publication="Physical Review Letters") public void initializeDegreeAssortativity()
public double degreeAssortativity()
@PublicationReference(title="Jaccard index", type=WebPage, year=2015, author="Wikipedia", url="https://en.wikipedia.org/wiki/Jaccard_index") public void initializePerEdgeJaccardSimilarity()
public double getEdgeJaccardSimilarity(int edgeId)
edgeId
- The [0..m) edge indexpublic void initializeEdgeTriangles()
public int numEdgeTriangles(int edgeId)
edgeId
- The edge whose triangle count is wantedpublic java.util.Set<java.lang.Integer> getEdgeTriangleOtherEndpointIds(int edgeId)
edgeId
- The edge whose triangles' third nodes are requestedpublic java.util.Set<NodeNameType> getEdgeTriangleOtherEndpointNames(int edgeId)
edgeId
- The edge whose triangles' third names are requestedpublic void initializePerEdgeTriangleDensity()
public double getPerEdgeTriangleDensity(int edgeId)
edgeId
- The edge whose density is requested@PublicationReference(author="Frank W. Takes and Walter A. Kosters", title="Computing the Eccentricity Distribution of Large Graphs", type=Journal, publication="Algorithms - Open Access Journal", year=2013, pages={100,118}, url="http://www.mdpi.com/1999-4893/6/1/100") public void initializePerNodeEccentricity()
@PublicationReference(author="Wikipedia", title="Dijkstra\'s algorithm", type=WebPage, url="https://en.wikipedia.org/wiki/Dijkstra%27s_algorithm", year=2016) public int[] computeAllDistancesForNode(int nodeId)
nodeId
- The node from which to start the searchpublic int getPerNodeEccentricityById(int nodeId)
nodeId
- The node whose eccentricity is requestedpublic int getPerNodeEccentricity(NodeNameType node)
node
- The node whose eccentricity is requestedpublic int getRadius()
public int getDiameter()
public boolean isWcc()
@PublicationReference(author="Ulrik Brandes", title="A Faster Algorithm for Betweenness Centrality", type=Journal, publication="Journal of Mathematical Sociology", year=2001, pages={163,177}) public void initializePerNodeBetweennessCentrality()
public double getPerNodeBetweennessCentralityById(int nodeId)
nodeId
- The node whose betweenness centrality is requestedpublic double getPerNodeBetweennessCentrality(NodeNameType node)
node
- The node whose betweenness centrality is requested