Skip to content

Commit 84d7b92

Browse files
authored
Apply suggestions from code review
Revisions.
1 parent b2bfc7d commit 84d7b92

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This library is distributed only via [NPM](npmjs.com). Install by running
2323
Require it in your code like this.
2424

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

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

9999
Constructs an instance of the graph data structure.
100100

101-
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)**.
101+
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)**.
102102

103103
### Adding and Removing Nodes
104104

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

107-
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.
107+
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.
108108

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

111111
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.
112112

113+
**Note:** You have to remove them using the exact same reference as when they were created. One can use getNode() to retrieve such reference.
114+
113115
### Adding and Removing Edges
114116

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

0 commit comments

Comments
 (0)