## #.hasNode

Returns whether the given node is found in the graph.

Example

``````graph.addNode('Timothy');

graph.hasNode('Timothy');
>>> true

graph.hasNode('Jack');
>>> false
``````

Arguments

• node any: node to find.

## #.hasEdge

Returns whether the given edge is found in the graph or whether an edge links the given source & target.

Example

``````graph.addNode('Timothy');

// Using the edge's key:
graph.hasEdge(edge);
>>> true

// Using the edge's source & target:
graph.hasEdge('Clarice', 'Timothy');
>>> true

graph.hasEdge('Clarice', 'John');
>>> false
``````

Arguments

1. Using the key:
• edge any: edge to find.
2. Using the source & target:
• source any: source of the edge to find.
• target any: target of the edge to find.

Variants

• `#.hasDirectedEdge`
• `#.hasUndirectedEdge`

## #.edge

Returns the key of the edge between given source & target or `undefined` if such an edge does not exist.

Note that this method will throw if either source or target is not found in the graph.

In addition, this method wonâ€™t work on a multi graph and will throw because the graph cannot know which edge to return since there might be multiple edges between source & target.

Example

``````graph.addNode('Timothy');

graph.edge('Clarice', 'Timothy');
>>> 'C->T'

graph.edge('Clarice', 'Olivia');
>>> undefined
``````

Arguments

• source any: source of the edge to find.
• target any: target of the edge to find.

Variants

• `#.directedEdge`
• `#.undirectedEdge`

## #.degreeWithoutSelfLoops

Returns the degree of the given node, without taking self loops into account.

Example

``````graph.addNodeFrom(['Timothy', 'Jack', 'Clarice', 'Martha']);

graph.degreeWithoutSelfLoops('Timothy');
>>> 3
graph.inWithoutSelfLoops('Timothy');
>>> 1
graph.outWithoutSelfLoops('Timothy');
>>> 2
``````

Arguments

• node any: target node.

Variants

• `#.inDegreeWithoutSelfLoops`
• `#.outDegreeWithoutSelfLoops`
• `#.directedDegreeWithoutSelfLoops` (`#.inDegreeWithoutSelfLoops` + `#.outDegreeWithoutSelfLoops`)
• `#.undirectedDegreeWithoutSelfLoops`
• `#.degreeWithoutSelfLoops` (`#.directedDegreeWithoutSelfLoops` + `#.undirectedDegreeWithoutSelfLoops`)

## #.degree

Returns the degree of the given node.

Example

``````graph.addNodeFrom(['Timothy', 'Jack', 'Clarice', 'Martha']);

graph.degree('Timothy');
>>> 3
graph.inDegree('Timothy');
>>> 1
graph.outDegree('Timothy');
>>> 2
``````

Arguments

• node any: target node.

Variants

• `#.inDegree`
• `#.outDegree`
• `#.directedDegree` (`#.inDegree` + `#.outDegree`)
• `#.undirectedDegree`
• `#.degree` (`#.directedDegree` + `#.undirectedDegree`)

## #.source

Returns the source of the given edge.

Example

``````graph.addNode('Timothy');

graph.source(edge);
>>> 'Clarice'
``````

Arguments

• edge any: target edge.

## #.target

Returns the target of the given edge.

Example

``````graph.addNode('Timothy');

graph.target(edge);
>>> 'Timothy'
``````

Arguments

• edge any: target edge.

## #.opposite

Given a node & an edge, returns the node at the other end of the edge.

Example

``````graph.addNode('Timothy');

graph.opposite('Timothy', edge);
>>> 'Clarice'
``````

Arguments

• node any: target node.
• edge any: target edge.

## #.extremities

Returns both extremities of the given edge.

Example

``````graph.addNode('Timothy');

graph.extremities(edge);
>>> ['Timothy', 'Clarice']
``````

Arguments

• edge any: target edge.

## #.hasExtremity

Returns whether the given edge has the given node as extremity.

``````graph.addNode('Lucy');

graph.hasExtremity(edge, 'Timothy');
>>> true

graph.hasExtremity(edge, 'Lucy');
>>> false
``````

## #.isDirected

Returns whether the given edge is directed.

Example

``````graph.addNode('Timothy');

graph.isDirected(edge);
>>> true
graph.isDirected(undirectedEdge);
>>> false
``````

Arguments

• edge any: target edge.

Variants

• `#.isUndirected`

## #.isSelfLoop

Returns whether the given edge is a self-loop.

Example

``````graph.addNode('Timothy');

graph.isSelfLoop(edge);
>>> true
``````

Arguments

• edge any: target edge.

## #.areNeighbors

Returns whether both nodes are neighbors.

Examples

``````graph.addNode('Timothy');

graph.areNeighbors('Clarice', 'Timothy');
>>> true

graph.areNeighbors('Zendar', 'Clarice');
>>> false
``````

Arguments

• node any: target node.
• neighbord any: potential neighbor.

Variants

• `#.areDirectedNeighbors`
• `#.areUndirectedNeighbors`
• `#.areInNeighbors`
• `#.areOutNeighbors`
• `#.areInboundNeighbors` (in + undirected)
• `#.areOutboundNeighbors` (out + undirected)