JgfGraph

JgfGraph

An graph object represents the full graph and contains all nodes and edges that the graph consists of.

Constructor

new JgfGraph(type, label, directed, metadata)

Source:
Constructor
Parameters:
Name Type Default Description
type string Graph classification.
label string A text display for the graph.
directed boolean true Pass true for a directed graph, false for an undirected graph.
metadata object | null null Custom graph metadata.

Members

edges

Source:
Returns all edges.

metadata

Source:
Sets the graph meta data.

metadata

Source:
Returns the graph meta data.

nodes

Source:
Returns all nodes.

Methods

addEdge(edge)

Source:
Adds an edge to the graph.
Parameters:
Name Type Description
edge JgfEdge The edge to be added.

addEdges(edges)

Source:
Adds multiple edges to the graph.
Parameters:
Name Type Description
edges Array.<JgfEdge> A collection of Jgf edge objects to be added.

addNode(node)

Source:
Adds a node to the graph.
Parameters:
Name Type Description
node JgfNode Node to be added.
Throws:
Error if the node already exists.

addNodes(nodes)

Source:
Adds multiple nodes to the graph.
Parameters:
Name Type Description
nodes Array.<JgfNode> A collection of Jgf node objects to be added.
Throws:
Error if one of nodes already exists.

getEdgesByNodes(source, target, relation)

Source:
Get edges between source node and target node, with an optional edge relation.
Parameters:
Name Type Default Description
source string Source node ID.
target string Target node ID.
relation string | null null If passed, only edges having this relation will be returned.

getNodeById(nodeId)

Source:
Get a node by a node ID.
Parameters:
Name Type Description
nodeId string Unique node ID.

removeEdge(edge)

Source:
Removes existing edge from the graph.
Parameters:
Name Type Description
edge JgfEdge Edge to be removed.

removeNode(node)

Source:
Removes an existing node from the graph.
Parameters:
Name Type Description
node JgfNode Node to be removed.