-
Notifications
You must be signed in to change notification settings - Fork 188
Network Utilities
Community detection algorithm (graph clustering/partitioning) based on the paper: Finding community structure in very large networks, A Clauset, MEJ Newman, C Moore - Physical review E, 2004
Returns an Array of communities, where each community is an Array of node ids belonging to that community.
Passed edges, a list of edge objects, and options, a dictionary of options with the following attributes:
Accepts the following values:
- undefined; every edge has default distance of 1
- constant; every edge has the same distance
- string; the name of the attribute in edge that describes the distance of that edge
- array; each value corresponds to the distance of the respective edge in the edges array
- function; given edge, returns the distance
Accepts the following values:
- undefined; then we assume that each node obtained by getting the endpoints of an edge is a string/number describing the id of the node
- string; the name of the attribute in node that describes the id of the node.
- function; given the node, returns the id.
Accepts the following values:
- undefined; it is assumed that edge.source points to the source node of the edge
- string; the name of the attribute in edge pointing to the source node of the edge
- function; given an edge returns the source node of that edge
Accepts the following values:
- undefined; it is assumed that edge.target points to the target of the edge
- string; the name of the attribute in edge pointing to the target of the edge
- function; given an edge returns the target node of that edge
If defined, the input is assumed to be normalized and nodes is assumed to be a dictionary that maps node id to the outedges of the node.
Returns the distance between two nodes. Expects the nodes in [x, y] format. If the nodes are objects, it will locate the "x" and "y" key.
Normalizes the graph input and checks if it is valid.
Finds the shortest paths between two nodes in a graph. Returns the top K shortest paths from the source to the given target, or the top K closest nodes to the source.
edges is a list of edge objects and source can be either a pointer to the source node/id or a string denoting the id of the source node.
options is a dictionary of options with the following attributes:
Accepts the following values:
- undefined; then the algorithm returns the closest nodes to the source
- pointer to the target node or its id
- string denoting the id of the target node
Specifies whether the graph is directed. Default is false
.
Accepts the following values:
- undefined; every edge has default distance of 1
- constant; every edge has the same distance
- string; the name of the atrribute in edge that describes the distance of that edge
- array; each value corresponds to the distance of the respective edge in the edges array
- function; given edge, returns the distance
Accepts the following values:
- undefined; then we assume that each node obtained by getting the endpoints of an edge is a string/number describing the id of the node
- string; the name of the attribute in node that describes the id of the node.
- function; given the node, returns the id.
Accepts the following values:
- undefined; it is assumed that edge.source points to the source of the edge
- string; the name of the attribute in edge pointing to the source of the edge
- function; given an edge returns the source node of that edge
Accepts the following values:
- undefined; it is assumed that edge.target points to the target of the edge
- string; the name of the attribute in edge pointing to the target of the edge
- function; given an edge returns the target node of that edge
Returns the top K results (defaults to 1). Depending on the target, it means:
- if target is specified, returns the top K shortest paths to the given target
- if target is undefined, returns the top K closest nodes to the given source
If defined, the input is assumed to be normalized and nodes is assumed to be a dictionary that maps node id to the outedges of the node.
Based on an Array of nodes, returns the distance between the 2 closest nodes using a d3.quadtree.
If an accessor function is provided, it will be passed the node and be expected to return an array containing [x,y]
.
Returns a graph object composed of nodes of distance K away from the source node and the links between them.
edges is a list of edge objects and source can be either a pointer to the source node/id or a string denoting the id of the source node.
options is a dictionary of options with the following attributes:
Returns the subgraph of nodes that are at most distance K from the source. Default is 1.
Whether the graph is directed. Default is false.
Accepts the following values:
- undefined; every edge has default distance of 1
- constant; every edge has the same distance
- string; the name of the atrribute in edge that describes the distance of that edge
- array; each value corresponds to the distance of the respective edge in the edges array
- function; given edge, returns the distance
Accepts the following values:
- undefined; then we assume that each node obtained by getting the endpoints of an edge is a string/number describing the id of the node
- string; the name of the attribute in node that describes the id of the node.
- function; given the node, returns the id.
Accepts the following values:
- undefined; it is assumed that edge.source points to the source of the edge
- string; the name of the attribute in edge pointing to the source of the edge
- function; given an edge returns the source node of that edge
Accepts the following values:
- undefined; it is assumed that edge.target points to the target of the edge
- string; the name of the attribute in edge pointing to the target of the edge
- function; given an edge returns the target node of that edge
If defined, the input is assumed to be normalized and nodes is assumed to be a dictionary that maps node id to the outedges of the node.