how get graph?

hi if I have data show users nd the relationships with other users, are there any way by which can draw such graph?
thanks in advance, huda

Answers (3)

Image Analyst
Image Analyst on 20 Apr 2012
I think you should know this, but I'll just throw out a wild guess: a scatter plot? If that's not what you want then you need to be more descriptive. These may help with that:
The "gray level co-occurrence matrix" (performed by the graycomatrix function in the Image Processing Toolbox) is one way of seeing relationships such as this where you want to see the relationship between every item and every other item. It's an image of "connection weights" though (like how many times those items occur together as a pair), rather than a graph-theory type of node diagram. It may or may not be helpful to you, since I tend to look at things through "imaging glasses." For example:
% Create sample data.
m = uint8([1,100;1,3;1,10;2,100;3,2;3,4])
% Computer glcm matrix.
gcm = graycomatrix(m, 'numlevels', 255)
imshow(gcm, []);
axis on;
title('Gray Level Co-occurrence Matrix', 'Fontsize', 30);
xlabel('Column 1 Value', 'Fontsize', 30);
ylabel('Column 2 Value', 'Fontsize', 30);
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
glcm is like a scatterplot where the intensity of the dots depends on the frequency of occurrence of that pair.
Walter Roberson
Walter Roberson on 20 Apr 2012

0 votes

This sounds like a traditional kind of graph-theory plot. Unfortunately once you get to about 6 nodes, you cannot necessarily draw the result as a planar graph, so you are going to have to be more specific about how you want the graphs drawn.

13 Comments

huda nawaf
huda nawaf on 21 Apr 2012
simple graph , just to see the structure of relations
but of course i have large size of users
thanks
huda nawaf
huda nawaf on 21 Apr 2012
walter, if i have txt file as
1 3 4 5 100
2 6 2 1 70 9
3 7 .........
.
.
etc
the first column of this txt file represent id of user and the other columns are friends of this user.
Now, i want graph show this relationships
thanks
Walter Roberson
Walter Roberson on 21 Apr 2012
You had better refer us to a sample of what you want the plot to look like.
huda nawaf
huda nawaf on 21 Apr 2012
ex.
sorce target
1 5
1 3
2 100
2 10
2 3
etc
these numbers are represent nodes of id's for users, i want graph show these relationships.
Walter Roberson
Walter Roberson on 21 Apr 2012
Please, a link to a sample plot. I could whip up code for plotting the information you have given, but that isn't going to do you any good if _my_ idea of what it is acceptable to look like, looks nothing like _your_ idea of what it must look like.
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
huda nawaf
huda nawaf on 21 Apr 2012
u can see this link to get idea of what i need
http://www.orient-lodge.com/node/3408
this software need programming
this is just example .
i deal with txt file in which two columns , the first one represent source node:
ex.
1
1
1
2
3
3
the second one is target node
100
3
10
100
2
4
there are edges between source node and target node (users)
ex. 1 is friend of 100 ,3 and 10, so there is edges between them and so for other users
many thanks walter
Walter Roberson
Walter Roberson on 21 Apr 2012
Yes, I understand your input, you do not need to repeat that.
Your input has relations between multiple nodes to multiple nodes, with none of the nodes being more important or the "center" of the graph. Your example graphs, however, have only one main node with connections to several other nodes, and has no examples of additional connections.
You need to give us an example of how you want your multiple-nodes to multiple-nodes to look. It makes big differences in the graphs. There are substantial differences in how one might place the nodes, and how one might arrange the multiple connections. How one is to deal with potentially crossing edges is quite important: the algorithms to avoid crossing edges get fairly complex.
huda nawaf
huda nawaf on 22 Apr 2012
I have not central node .
I just need see the structure of networks of relations .
I have large set of users , and important for me to see the relations among them.
walter, may be find out many things after see the networks of relations.
I need simple graph.
thanks
Walter Roberson
Walter Roberson on 22 Apr 2012
Let SRC be a *column* vector of the source nodes. Let TARG be a *column* vector of the target nodes.
plot( ones(size(SRC)), [SRC, TARG].' )
Of course, this will plot everything in a single column, and the lines will overlap each rather other badly.
If this wasn't what you wanted, you should have given an example of what you did want, and someone else will have to help you with it, as 3 times asking for an example is the limit of my patience.
Walter Roberson
Walter Roberson on 22 Apr 2012
Note: I do not download files sent to me without warning, as I get many attempts to get me to read Nigerian scam messages and attempts to get me to download malware.
If I were to be sent a sample graph or problem document related to this thread, I probably wouldn't look at it, as I am already out of patience. Someone could, however, post a link to an image or document as someone else might look at it.
http://www.mathworks.com/matlabcentral/answers/7924-where-can-i-upload-images-and-files-for-use-on-matlab-answers
Oleg Komarov
Oleg Komarov on 22 Apr 2012
@Walter: your help is much needed in places where (at least) effort is.
Geoff
Geoff on 23 Apr 2012
Sounds like the required solution to this problem is to write a program which generates a GraphViz script, then install GraphViz and run the script.
huda nawaf
huda nawaf on 24 Apr 2012
thanks for advice,
i did but with gephi software, no need a script

Sign in to comment.

Christine Tobler
Christine Tobler on 22 Nov 2019

0 votes

Since MATLAB R2015b, there are Graph and Network Algorithms in MATLAB that will allow you to construct and plot a graph of these relationships. Several layout options are available, using plot(mygraph, 'Layout', 'force'), for example.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Asked:

on 20 Apr 2012

Answered:

on 22 Nov 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!