NetworkX - multigraphs

https://networkx.org/documentation/stable/reference/classes/multigraph.html

https://networkx.org/documentation/stable/reference/classes/multidigraph.html

INTRODUCTION

A 'multigraph' is a graph which is permitted to have multiple edges (parallel edges), that is, edges that have the same end nodes. A 'loop' is an edge that connects a vertex to itself.


import networkx as nx

G = nx.MultiGraph()   # an undirected multigraph
H = nx.MultiDiGraph()   # a directed multigraph