Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Revisions.
  • Loading branch information
curran authored Oct 23, 2024
1 parent b2bfc7d commit 84d7b92
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This library is distributed only via [NPM](npmjs.com). Install by running
Require it in your code like this.

```javascript
const { Graph, serializeGraph, deserializeGraph, topologicalSort, shortestPath } = require('graph-data-structure');
import { Graph, serializeGraph, deserializeGraph, topologicalSort, shortestPath } from 'graph-data-structure';
```

## Examples
Expand Down Expand Up @@ -98,18 +98,20 @@ For more detailed example code that shows more methods, have a look at the [test

Constructs an instance of the graph data structure.

The optional argument _serialized_ is a serialized graph that may have been generated by **[serializeGraph](#serializeGraph)**. If _serialized_ is present, it is deserialized by invoking **[deserializeGraph](#deserializeGraph)**.
The optional argument _serialized_ is a serialized graph that may have been generated by **[serializeGraph](#serializeGraph)**. If _serialized_ is present, it is deserialized by invoking **[deserializeGraph(mySerializedObject)](#deserializeGraph)**.

### Adding and Removing Nodes

<a name="add-node" href="#add-node">#</a> <i>graph</i>.<b>addNode</b>(<i>node</i>)

Adds a node to the graph. Returns _graph_ to support method chaining. The argument _node_ can be any object or string that uniquely identifies the node within this graph instance. If a node with the same identifier was already added to the graph, this function does nothing.
Adds a node to the graph. Returns _graph_ to support method chaining. If the given _node_ was already added to the graph, this function does nothing.

<a name="remove-node" href="#remove-node">#</a> <i>graph</i>.<b>removeNode</b>(<i>node</i>)

Removes the specified node. Returns _graph_ to support method chaining. The argument _node_ is a string or object identifier for the node to remove. This function also removes all edges connected to the specified node, both incoming and outgoing.

**Note:** You have to remove them using the exact same reference as when they were created. One can use getNode() to retrieve such reference.

### Adding and Removing Edges

<a name="add-edge" href="#add-edge">#</a> <i>graph</i>.<b>addEdge</b>(<i>u</i>, <i>v</i>[,<i>weight</i>])
Expand Down

0 comments on commit 84d7b92

Please sign in to comment.