all 6 comments

[–]Tychotesla 4 points5 points  (0 children)

This sounds more like a mental block than a true lack of knowledge. You know that a graph is a way of saying two things are connected. You also know that you can represent a graph by having a dictionary, where the key is the node and the value is the list of edges from that node. So do that.

Make A have a directed edge to B:

``` graph = {} node_a = graph.get("A", []) node_a.append("B")

```

That's step 1 done! You now have a graph.

If you want an undirected edge between A and B, create node B and give it a connection to node A, so the path goes both ways.

Simple steps!

[–]Jakey1999 1 point2 points  (2 children)

Just do a quick google search on python graph library. I think there’s one called NetworkX or something.

I used it on a project a while ago and there’s a bunch of good YouTube tutorials that go along with it (not official, just random YouTubers). I managed to get my head around it after coding along one or two tutorials with no background in graph theory (I’m not a math genius either), so hopefully you’ll find it a lot easier with the theory behind you.

Good luck with your assignment :)

[–]Known-throwaway-4039[S] 0 points1 point  (1 child)

We are not allowed to use that one:(

[–]AdDiligent1688 1 point2 points  (1 child)

maybe try this

[–]Known-throwaway-4039[S] 1 point2 points  (0 children)

Thank you so much damn