CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2010
    Posts
    2

    Adjacency Matrix Representation

    In an adjacency matrix for an undirected graph ,almost half the storage space required by the graph is unnecessary (the have 0 value).
    please suggest a modification that uses less space

    Regards
    Harsh Jain

  2. #2
    Join Date
    May 2009
    Posts
    2,413

    Re: Adjacency Matrix Representation

    You mean that the array in principle consists of two triangles, one above the diagonal and one below the diagonal, and that they essentially hold the same information?

    Then you can organize the matrix as an array of arrays. If the inner-most arrays have different lengths this is called a jagged matrix. In your case the inner-most arrays will have increasing lengths starting at 1, like

    *
    * *
    * * *
    * * * *

    etcetera.

    Just make sure the first index is bigger than the second when you access it, otherwise you need to swap them first.
    Last edited by nuzzle; January 26th, 2010 at 12:39 PM.

  3. #3
    Join Date
    Jan 2010
    Posts
    22

    Red face Re: Adjacency Matrix Representation

    Quote Originally Posted by harsh4u8 View Post
    In an adjacency matrix for an undirected graph ,almost half the storage space required by the graph is unnecessary (the have 0 value).
    please suggest a modification that uses less space

    Regards
    Harsh Jain
    My mothod is the same as yours at present

  4. #4
    Join Date
    Jan 2010
    Posts
    5

    Re: Adjacency Matrix Representation

    Implement it as a list. If you maintain an Adjacency Matrix, you can never get rid of the redundant entries.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured