Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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.

share

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.