Skip to main content

Home > @jsplumbtoolkit/core > Graph

Graph class

Signature:

export declare class Graph 

Constructors

ConstructorModifiersDescription
(constructor)(params)Constructs a new instance of the Graph class

Properties

PropertyModifiersTypeDescription
_defaultIdFunctionIdFunction
_edgeMapMap<string, Edge>
_groupMapMap<string, Group>
_nodeMapMap<string, Node>
_topLevelCacheRecord<string, Vertex>
defaultCostnumber
defaultDirectedboolean
edgesArray<Edge>
enableSubgraphsboolean
groupsArray<Group>
idstring
nodesArray<Node>
portSeparatorstring
typeFunctionTypeFunction

Methods

MethodModifiersDescription
addEdge(params, idFunction, connectableFilterFunction)Adds an edge to the graph.
addGroup(data, idFunction)Adds a Group to the Graph.
addMembersToGroup(v, g)
addMemberToGroup(v, g)
addNode(data, idFunction)
addNodes(data, idFunction)Adds a list of Nodes to the Graph
clear()
deleteEdge(edge)Deletes an Edge.
deleteGroup(g, removeMembers)Deletes a Group
findPath(source, target, strict, nodeFilter, edgeFilter)Finds the shortest path from source to target, using the Djikstra algorithm.
getAllEdges()Gets every edge in the Graph.
getAncestors(vertex)Gets a list of groups that are ancestors of the given node/group. The list of ancestors is ordered in terms of their proximity to the focus, ie. the first entry is the focus vertex's immediate parent.
getBetweenness(vertex)Returns the betweenness centrality of the given node.
getCentrality(node)
getCloseness(vertex)Returns the Closeness centrality of the given vertex. This is the inverse of the vertex's farness.
getClusters()Calculates "clusters" of nodes (and groups), where a 'cluster' is a set of Nodes/Groups that are connected. Direction of connections is not taken into account. Nodes that are children of Groups are included in all cluster calculations, which might cause some weird situations, but this functionality is mostly intended just for Nodes anyway.
getDiameter(dontUseMax)Returns the diameter of the Graph.
getDistance(source, target, strict)Finds the distance between source and target.
getEdge(e)Gets an Edge by id, or if the given object is already an Edge, hands that back.
getEdgeCount()Returns the total number of Edges in the graph.
getEdges(params)For some given node, get a subset of edges that match the given filter function.
getFarness(vertex)Returns the farness centrality of the given node, ie. the sum of its distance from all other nodes, where the distance from one vertex to another is given by the associated cost of the Edge joining the two nodes.
getGroup(group)
getGroupAt(idx)Returns the Group at the given index.
getGroupCount()
getGroups()Gets the Groups in the graph.
getId(data, idFunction)
getIdFunction()
getIndegreeCentrality(vertex)Returns the indegree centrality of the given vertex (number of connections entering the vertex)
getOutdegreeCentrality(vertex)Returns the outdegree centrality of the given vertex (number of connections exiting the vertex)
getPortSeparator()Gets the current port separator.
getTopLevelElements()
getType(data)Gets the type for some data, by running it through the current typeFunction.
getVertex(e, createPortsIfMissing)
getVertexAt(index)Returns the vertex at the given index (used for bulk init type purposes)
getVertexByPortId(portId)Looks up a vertex identified by the port id, which is in full port id (vertexId.portId) format, returning null if nothing found. (Note that we show full port id format as vertexId.portId, but the '.' is just the default portSeparator; it is possible to change that to some other character)
getVertexCount()Gets the count of nodes in the Graph.
getVertices()Gets all the nodes in the Graph.
inspect()
isAncestor(focus, possibleAncestor)Returns whether or not possibleAncestor is in fact an ancestor of the given focus node/group
printPath(source, target)Returns the path from source to target as a string.
removeMemberFromGroup(v)
removeMembersFromGroup(v)
renamePort(port, newId)
serialize()
setEnableSubgraphs(enable)Sets whether or not Nodes are Graphs themselves, and can have child Nodes. If you enable this then you cannot use slashes (/) in your Node ids, as they will be treated as components of a path to a Node in a nested Graph.
setIdFunction(f)
setPortSeparator(separator)Sets the character(s) used to separate ports from nodes in port ids. By default this is '.', ie a port is addressed as nodeId.portId. This may need to be changed depending on the data in your model.
setSource(edge, o)Sets the source Group/Node/Port for some Edge.
setTarget(edge, o)Sets the target Group/Node/Port for some Edge.
setTypeFunction(f)
splitPortId(portId)Splits the given port id using the current portSeparator.