i have successfully implemented several algorithms and data structures. however, i am not sure how i would implement a graph algorithm, since i would need to represent a graph then. i'm trying to implement algorithms and data structures from introduction to algorithms by cormen et. al. however, many algorithms take a graph as an input or they take a tree structure as input, which you cannot just provide as text either. i don't know how to implement dijkstra, bellman-ford, floyd-warshall, kruskal etc. can i represent any graph as a matrix, even if it is a weighted or directed graph? because i think i can use multidimensional arrays for matrices. i think 0 or 1 could indicate whether there is an edge or not, but i'm not really sure how i would represent any graph using a matrix. and what about a binary tree, if an algorithm take that as an input?
thanks in advance.