Since I have many of my own functions, I plan to organize them into separate modules according to their functionality for easier reuse. I performed the following test by first creating a file zg.py, which contains:
def create_graph():
G = Graph()
G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
return G
When I create a new Sage file and try to call it, the following error appears. Why is this happening?
from zg import create_graph
create_graph()
NameError Traceback (most recent call last)
Cell In[7], line 1
----> 1 create_graph()
File /mnt/d/sage_z/new_fun/common_z.py:81, in create_graph()
80 def create_graph():
---> 81 G = Graph()
82 G.add_edges([(0, 1), (1, 2), (2, 3), (3, 0)])
83 return G
NameError: name 'Graph' is not defined