How to represent a strange graph in some data structure

后端 未结 3 1349
执念已碎
执念已碎 2021-02-03 11:23

A simple way to represent a graph is with a data structure of the form:

{1:[2,3],
 2:[1,3],
 3:[1,2]}

Where the keys in this dictionary are nod

3条回答
  •  悲哀的现实
    2021-02-03 12:07

    This could be represented by a directed graph.

    Nodes in your graph could be represented as two nodes in the graph. Think of the nodes as representing locations on particular sides of a street -- the edges being like inbound and outbound lanes.

    enter image description here

提交回复
热议问题