I am trying to learn graph structures and algorithms. Conceptually I understand DFS, BFS, and I can implement them provided a graph, but how are graphs traditionally composed?
Typically I see them as list of nodes with edges as pointers, a list of edges with the nodes they connect, or a 2d matrix where the intersection of both arr[node_a][node_b] is the weight of the edge.
When it comes to actually building it out of input, I don't know where to start.
As an example, how you would you build a graph when provided a 2d grid like (an online pacman problem) where P is the source node and -'s are nodes in the tree.
%%%%%%%%%%%%%%%%%%%%
%--------------%---%
%-%%-%%-%%-%%-%%-%-%
%--------P-------%-%
%%%%%%%%%%%%%%%%%%-%
%.-----------------%
%%%%%%%%%%%%%%%%%%%%
Or, how would you build it when provided with an adjacency list?
I understand this is probably a big question, as the subject is rather complicated. Links to documentation are appreciated! I've been having trouble finding any from an introductory level.