Representing graphs (data structure) in Python

前端 未结 4 452
-上瘾入骨i
-上瘾入骨i 2020-11-28 18:06

How can one neatly represent a graph in Python? (Starting from scratch i.e. no libraries!)
What data structure (e.g. dicts/tuples/dict(tuples)) will be fast but also mem

4条回答
  •  借酒劲吻你
    2020-11-28 18:28

    There are two excellent graph libraries NetworkX and igraph. You can find both library source codes on GitHub. You can always see how the functions are written. But I prefer NetworkX because its easy to understand.
    See their codes to know how they make the functions. You will get multiple ideas and then can choose how you want to make a graph using data structures.

提交回复
热议问题