What are the suitable data structures for graphs ?
I guess the answer varies on the type of graph?
in any case, any recommendations?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Seeing as you want an abstract data type, I won’t mention anything about implementation.
A graph
G = <V, E>is a set of verticesV, and a set of edgesEwhere each element inEis a tuplee = <v1, v2>, andv1andv2are inV.The following may look like Java but I’m really thinking of any sufficiently expressive language:
I think this is the bare minimum. I haven’t specified what is returned by
getEdges; if the language has a native tuple type it would a set of those. In practice you would want to add extra methods such as:etc.
Extending this to digraphs is left as an exercise
:-).