Thread: how to create an adjacency matrix?

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    13

    how to create an adjacency matrix?

    i want to input values as

    a[0][0]=1 a[0][1]=3
    a[1][0]=2 a[1][1]=3

    1 3
    2 3

    i want an adjacency matrix from this as:
    m[0][0]=0, m[0][1]=0, m[0][2]=1
    m[1][0]=0, m[1][1]=0, m[1][2]=1
    m[2][0]=1, m[2][1]=1, m[2][2]=0

    0 0 1
    0 0 1
    1 1 0

    How can i do?
    please help me with codes....

  2. #2
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    How do you want the program to run?

    I'd imagine that you prompt the user to enter connections and save a 1 in the corresponding place for the adj matrix

    i.e.
    _______________________

    Enter Connection:
    add 1-3
    OK

    add 2-3
    OK

    add 3-3
    OK

    del 3-3
    OK

    print
    OK

    0 0 1
    0 0 1
    1 1 0
    ________________________________

    Is this what you want?
    Fact - Beethoven wrote his first symphony in C

  3. #3
    Registered User
    Join Date
    Sep 2012
    Posts
    13
    yes right!

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    OK - Let's start with the first command

    Prompt for input and read the response.

    You will need to start this on your own - printf and scanf are probably a good starting point
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. adjacency matrix and sparse matrix
    By dpp in forum C Programming
    Replies: 3
    Last Post: 07-11-2010, 10:26 AM
  2. Replies: 1
    Last Post: 11-06-2008, 11:50 PM
  3. Help w/ graph as adjacency matrix
    By ac251404 in forum C++ Programming
    Replies: 4
    Last Post: 05-09-2006, 10:25 PM
  4. Help with adjacency matrix and scanf
    By hollywoodcole in forum C Programming
    Replies: 5
    Last Post: 03-30-2005, 04:31 PM
  5. adjacency matrix
    By Smiley0101 in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2003, 09:17 PM

Tags for this Thread