codezonediitj / pydatastructs

A python package for data structures and algorithms
https://pydatastructs.readthedocs.io/en/stable/
Other
201 stars 267 forks source link

Add note in Graph doc string for clarifying adding nodes and edges #423

Closed czgdp1807 closed 2 years ago

czgdp1807 commented 2 years ago

Description of the problem

The correct way to create a graph is to first create nodes of the right type (AdjacencyListGraphNode or AdjacencyListMatrixNode) and then add these nodes to the graph. Once done, add edges between these nodes.

  1. A note should be added in the class doc string for the above process.
  2. In the doc string of add_edge it should be clarified that this function will assume that the nodes are already present in the graph. If they are not present, then this function will not add the new nodes on it's own. In case someone attempts to do that then a nice error message should be raised describing the same.

Example of the problem

References/Other comments

cc: @pratikgl