Results 1 to 5 of 5
Thread: graph with its demands
 07222013, 03:21 PM #1Member
 Join Date
 Jul 2013
 Posts
 1
 Rep Power
 0
graph with its demands
hello i am new to java
I need to write a graph with some nodes v={1,2,3,4,5,6,7} and edges E={(12),(23), (3,4),(47), (36), (26), (56), (15)} and also with some demands D=(s,d)={(13),(23), (45). (77), (64),(27)} which are some path with an exact source an destination for this network. How can I write this in Java? Can anyone help me please?
 07232013, 07:10 AM #2
Re: graph with its demands
I've never encountered the term "demands" in relation to graphs... but a graph is completely defined by its nodes and edges. Seems like you just need to write classes for Node and Edge and give them the appropriate properties.
Get in the habit of using standard Java naming conventions!
 07232013, 10:30 AM #3
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,423
 Blog Entries
 7
 Rep Power
 27
Re: graph with its demands
Nodes can have 'supplies' or 'demands'. The sum of both can be equal and the problem can be solved such that the costs over each edge is minimal. It's a classic assignment or transportation problem. But we don't know if the OP wants to solve anything or just make a model for the problem (which is a graph with supplies/demands on the vertices). The OP has to give more details ...
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 07232013, 08:28 PM #4
Re: graph with its demands
Ah. Are supply and demand related to flow? Sounds like it might be the same properties I learned to call source and sink.
Get in the habit of using standard Java naming conventions!
 07232013, 08:37 PM #5
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,423
 Blog Entries
 7
 Rep Power
 27
Re: graph with its demands
Yep, flow goes over the edges/arcs, as much as supply/demand dictate; the generalized problem is an mcnf (Minimal Cost Network Flow) problem which has an integer solution iff the demands and supplies are integer. Solving such a problem if it has upperbounds on flow over its edges can be nasty if you have the wrong representation of the graph ...
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
Similar Threads

scrollable graph on JFrame. (I've made the graph and I need it scrollable)
By noobplus in forum AWT / SwingReplies: 16Last Post: 03212012, 10:41 AM 
Graph in Jsp
By monika in forum New To JavaReplies: 0Last Post: 04202010, 06:47 PM 
ECG Graph
By bharath333 in forum Java AppletsReplies: 4Last Post: 02142009, 11:26 PM 
Bar Graph
By Zosden in forum Advanced JavaReplies: 2Last Post: 04282008, 07:52 AM
Bookmarks