You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The add edge method may take an optional weight with default value 1 so that the class can also be used as an unweighted graph. However, pedagogically it may be better to have a simpler superclass for unweighted graphs. The exact class hierarchy for un/weighted di/graphs requires a bit of thinking. It would be good to allow extension in future to non-simple graphs.
In networkx, digraph is a subclass of undirected and stores both the out- and in-neighbours. Arbitrary attributes can be attached to a graph, a node or an edge. Weight is just an attribute like any other. Both classes allow loops. There are two separate classes for graphs with multi-edges.
You may copy and adapt code from Section 18.2.2 of the M269 book. You may divide the tasks below with others, to reduce workload.
Create a file
paddles/digraph.py
with a classAdjacencyMapWeightedDiGraph
:ValueError
if the node doesn't exist)ValueError
if the node doesn't exist)ValueError
if the edge – i.e. either node – doesn't exist)ValueError
if the node already exists)ValueError
if the node to remove doesn't exist)ValueError
if the edge is between the same node – a loop)ValueError
if the edge to remove doesn't exist)Create a file
tests/test_digraph.py
:The text was updated successfully, but these errors were encountered: