You are not logged in. Please login at to post your questions!


Adjacency list

Can anyone give me a code of using adjacency lists to represent a graph using arrays only( perhaps by using an 2D array).

asked 16 Jan '15, 18:21

anupam_datta's gravatar image

accept rate: 7%

I was in the same position as you are just a few weeks back. In fact, I haven't even practiced enough graph problems. I wanted answers only in terms in what I know. But trust me, arrays are a lot more harder to maintain adjacency lists. Anyway, you can check these out

A better option would be to use an array of vectors or a vector of vectors whose size can be adjusted dynamically, you don't have to specify it in advance. To use a vector of vectors to maintain an adjacency list, google how it works and for a better understanding refer this, an implementation of the FIREESC problem

Hope it helps!


answered 16 Jan '15, 23:31

sandy999's gravatar image

accept rate: 10%

edited 17 Jan '15, 14:17

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 16 Jan '15, 18:21

question was seen: 1,028 times

last updated: 17 Jan '15, 14:17

Related questions