473,327 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

nodes to adjacency matrix

Hi All,

Please suggest the best way to build an adjacency matrix from given nodes and links.
my input wil be as shown
3 2
n1 n2 3
n3 n1 2

The first row 3 represents number of nodes,
and 2 represnets number of links.
the following two lines represent edges/connects and the numbers 3,2 represent that they are weighted ones.

how can I form an adjacency matrix from the given input?

Thanks in advance,
Anil kumar Y.
A suggestion can make a difference.
Apr 16 '10 #1
9 3835
Dheeraj Joshi
1,123 Expert 1GB
Adjacency Matrix
Google result

Above links may help you.

Regards
Dheeraj Joshi
Apr 16 '10 #2
Hi Dheeraj,

thanks for the reply,
I understood the concept of adjacencny which same is explained in the links given by you,
i want to implement the scenario which i mentioned above.

Thanks,
AnilKumar Y.
Apr 16 '10 #3
Dheeraj Joshi
1,123 Expert 1GB
Is your graph is directed? or it is undirected?

Regards
Dheeraj Joshi
Apr 16 '10 #4
its a directed one dheeraj......

Thanks,
Anil Kumar Y.
Apr 16 '10 #5
Dheeraj Joshi
1,123 Expert 1GB
Take the weight of the edge from user or from a file and put it in the matrix.

Example
4 2
i.e n1 --> n2 <-- n3 is your graph:

you can ask user first for weight for edge n1 --> n1 then from n1 --> n2 and then to n1 --> n3. Similarly for other nodes also.

Or take the input from file and place the value in matrix.

file input will be
Expand|Select|Wrap|Line Numbers
  1. 0  4  0 
  2. 0  0  0
  3. 0  2  0
  4.  
Regards
Dheeraj Joshi
Apr 16 '10 #6
3 2
n1 n2 3
n3 n1 2

The first row 3 represents number of nodes,
and 2 represnets number of links.
the following two lines represent edges/connects and the numbers 3,2 represent that they are weighted ones.

if u check that we are already getting weights as inputs for the links in the input file.
n1-->n2 weight is 3
and n3-->n1 weight is 2.

iam very new to this concept.
I want to know how we can build a matrix after receiving the input.

I would be thankful if u place the code.

Thanks ,
Anil Kumar Y.
Apr 16 '10 #7
Dheeraj Joshi
1,123 Expert 1GB
In my previous post i gave an example graph and inputs.

I can not place the code. Its against the forum rules. I can point out the errors in your code.

Please write code on your own. And let us know in case of any errors.

Regards
Dheeraj Joshi
Apr 16 '10 #8
hey iam too new to code on my own
can anyone guide me in step by step manner
Apr 16 '10 #9
jkmyoung
2,057 Expert 2GB
I would suggest creating an integer matrix. Are you using c or c++?

Something like directedMatrix in a int[numNodes][numNodes]

You may also want to look at Arrays Revealed
Apr 16 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: SallyBenjamin | last post by:
Hello.. Can anyone help me with this coding. Basically, it needs to have add node, remove node, add edges , remove edges and display the graph But.I have only succedded to add node, add and...
6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
0
by: Jef Driesen | last post by:
I need some help to implement the adjacency list representation of a (undirected) graph. The data structure I need is something like the picture on the website...
19
by: Christian Fowler | last post by:
I have a VERY LARGE pile of geographic data that I am importing into a database (db of choice is postgres, though may hop to oracle if necessary). The data is strictly hierarchical - each node has...
12
by: Steve | last post by:
I have been studying the Adjacency List Model as a means of achieving a folder structure in a project I am working on. Started with the excellent article by Gijs Van Tulder ...
0
by: amodagni | last post by:
Hi ! Could someone please guide me to SQL code required for managing data in tables in which hierarchical data stored in adjacency or Nested set model.
1
by: madhuparna | last post by:
Plzz give the code for implementing adjacency matrix in C
0
by: ZoeNet | last post by:
Hi all, The table structures are below. The table category_cat is built on the adjacency model (where the parent and child entries are both stored in the same table). For my problem, I've...
2
by: orzeech | last post by:
Here's my code that's supposed to be a basic graph implementation using adjacency lists. It comes straight from R.Sedgewick's "Algorithms in C++". However "23 - ISO C++ forbids declaration of...
0
by: kantai | last post by:
Need help in solving the problem below. Any help would be highly appreciated Implement the adt graph as a C++ class first by using an adjacency matrix to represent the graph then by using an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.