Multi Graphs

General discussion about Mathematica features and functionality...
Forum Rules
By using the Wolfram Faculty Program Forum, you agree not to post any abusive, obscene, vulgar, slanderous, hateful, threatening, or sexually oriented material. Wolfram Faculty Program Forum administrators have the right to remove, edit, move or close any topic at any time should we see fit.

Personal Information: Posts in this forum may be viewed by non-members; however, the forum prohibits non-members from viewing your profile. Although your email address is hidden from both non-members and members, your account is initially configured to allow members to contact you via email through the forum. If you wish to hide your profile, or prohibit others from contacting you directly, you may change these settings by updating your profile through the User Control Panel.

Attachments: Attachments are not currently enabled on this forum. To share a file with others on this site, simply upload your file to the online storage service of your choice and include a link to the file within your post. If your school does not offer an online file storage and sharing service, the following sites provide free basic online file storage and sharing: Mozy, FilesAnywhere, Adrive, and KeepandShare.

Multi Graphs

Postby Keerti_Vardhan » Thu Jul 15, 2010 3:52 pm

1. Can someone tell me why I am not getting a multi graph by typing the following command?

GraphPlot[{{0, 2}, {2, 0}}//MatrixForm]


2. For a given multi graph I know how to find its Adjacency Matrix but I am unable to draw a multi graph corresponding to a given matrix. Please help.
User avatar
Keerti_Vardhan
 
Posts: 5
Joined: Thu Apr 22, 2010 1:37 pm
Organization: Panjab University
Department: Mathematics

Re: Multi Graphs

Postby Ken_Levasseur » Sat Jul 17, 2010 11:00 am

The expression {{0, 2}, {2, 0}} is already a matrix, and MatrixForm doesn't help here.

The entries in a matrix that defines a graph are taken to be weights, not numbers of edges. I've used this function to draw multigraphs. It assumes that the matrix entries are nonnegative integers:

Code: Select all
MultiEdgeList[g_] := Module[{edgelist = {}},
  NestWhile[(edgelist = Join[edgelist, EdgeList[#]];
     Map[Max[0, # - 1] &, #, {2}]) &, g, (Plus @@ Flatten[#] > 0) &];
  Map[Rule @@ # &, edgelist]]


This will then draw the graph I think you expect to see:

Code: Select all
GraphPlot[MultiEdgeList[{{0, 2}, {2, 0}}], DirectedEdges -> True]


Ken Levasseur
UMass Lowell
User avatar
Ken_Levasseur
 
Posts: 1
Joined: Mon Feb 01, 2010 6:14 pm
Organization: UMass Lowell
Department: Mathematical Sciences

Re: Multi Graphs

Postby Keerti_Vardhan » Sun Jul 18, 2010 11:52 am

Dear Ken_Levasseur
Thanks for your reply. Later I found following command to plot multi graphs
GraphPlot[{{0,2},{2,0}},MultiedgeStyle -> True]

Kindly let me know the purpose of your first code i.e.
MultiEdgeList[g_] := Module[{edgelist = {}},NestWhile[(edgelist = Join[edgelist, EdgeList[#]];
Map[Max[0, # - 1] &, #, {2}]) &, g, (Plus @@ Flatten[#] > 0) &];
Map[Rule @@ # &, edgelist]].

I am unable to use this code on my computer.

Regards
Keerti Vardhan
User avatar
Keerti_Vardhan
 
Posts: 5
Joined: Thu Apr 22, 2010 1:37 pm
Organization: Panjab University
Department: Mathematics


Return to General Mathematica Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron