diff --git a/README.md b/README.md index f635df3..9e8f10b 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 # graph.addNode(node) -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. # graph.removeNode(node) 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 # graph.addEdge(u, v[,weight])