I want to input a matrix (dictionary with a node as the key, and all adjacent nodes in a set as the key [Nodes are represented as integers which are indexes to another dictionary that contains the objects the nodes represent {cells in a maze if anyone is curious}]) and have a graphic that shows the graph with each node labelled, with lines connecting each node.
If there is no convenient way to do this with the format I have posted then it is not too important, but it would be very helpful for my writeup if I could have images of all graphs, and have it ideally done automatically as there will be several in the document.
Python3 btw
I would post the code in question, however, it is part of a larger project for my A-Level Computer Science Coursework and as such has many elements to it.
What you are looking for is Networkx. This python library can help you draw your graphs by just inputting the nodes and edges. here are some sample code.
pip install networkx #for installing the library
for creating a graph
import networkx as nx
G = nx.Graph()
for adding nodes
G.add_node(1)
or multiple nodes
G.add_nodes_from([2, 3])
you can add edge such as
G.add_edge(1, 2)
and finally to display you can do
nx.draw(G)
plt.show()
here is a complete sample run
import networkx as nx
import matplotlib.pyplot as plt
G = nx.Graph()
G.add_edges_from(
[('A', 'C'), ('D', 'B'), ('E', 'C'), ('E', 'F'),
('B', 'H'), ('B', 'F'), ('C', 'G')])
nx.draw(G,with_labels=True)
plt.show()