Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7703975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:34:53+00:00 2026-05-31T23:34:53+00:00

I was just wondering how you can use and adjacency matrix to solve graph

  • 0

I was just wondering how you can use and adjacency matrix to solve graph problems.

For example for my program I have an exchange rate for two items.

Input to build a directed graph: 6 shirts 15 socks
Input to build a directed graph: 2 socks 1 underwear

Directed graph:

shirts –(6/15)– socks –(2/1)– underwear

So the edge from shirts to socks is 6, edge from socks to shirts is 15, socks to underwear is 2 and underwear to socks is 1.

Input to compare: socks shirts
Solution : 15 socks 6 shirts

Input to compare: shirts underwear
Soltuion : 12 shirts 15 underwear

My question is how can I represent this with an adjacency matrix and be able to get its weight to solve the problem.

I was thinking of having an adjacency matrix that would look like this for the above problem.

          shirts   socks  underwear
shirts    [ 0       6     0 ]
socks     [ 15      0     2 ]
underwear [ 0       1     0 ]

Is this a good start? I’m trying to get the logic before the code.

Just looking for some more information on how to do this on a bigger scale with more items and separate graphs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:34:54+00:00Added an answer on May 31, 2026 at 11:34 pm

    I will give you a basic hint on what is an adjacency graph. Solving your problem is your homework so I cannot do it.

    Imagine the following graph:

        A-----B
       / \   | \
      /   \  |  \
     /     \ |   \
    C-------D-----E
    

    An adjacency matrix tells which node in the graph is connected to which:

        A  B  C  D  E
    A [ 0  1  1  1  0 ]
    B [ 1  0  0  1  1 ]
    C [ 1  0  0  1  0 ]
    D [ 1  1  1  0  1 ]
    E [ 0  1  0  1  0 ]
    

    For example entry (D, E) shows that D and E are connected, while (A, E) shows that A and E are not. Note that this matrix is symmetric because the graph is undirected.

    If the matrix is weighted as follows:

        A--3--B
       / \   | \
      5   3  2  1
     /     \ |   \
    C---2---D--7--E
    

    then the adjacency matrix shows which are connected and with what weight (assuming 0 shows no connection):

        A  B  C  D  E
    A [ 0  3  5  3  0 ]
    B [ 3  0  0  2  1 ]
    C [ 5  0  0  2  0 ]
    D [ 3  2  2  0  7 ]
    E [ 0  1  0  7  0 ]
    

    In your case, your graph is a bunch of nodes having edges to a bunch of other nodes. Your adjacency matrix would look very similar to what you have already come up with, but the values might not be correct. The values should be either the same, negative of each other or 1 over the other, depending on what your algorithm is going to be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have use rails3-jquery-autocomplete plugin and I am just wondering how can I use
I have an autocomplete field and am just wondering how can i use it
I've been wondering if I can use <p>&nbsp;</p> (just space in paragraph) instead of
Just wondering how I can paste an object after I have selected it in
Just wondering if anyone knows of a jQuery sortable plugin that I can use
Just wondering how I can use an element as the text of another element
Just wondering if anyone know if in general you can use the MVC UI
This is a trivial question, I was just wondering if I can use something
I am just wondering how I can use a Master/Slave MySQL replication database with
I'm just wondering if you can use both of them in a PHP code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.