Results 1 to 5 of 5
  1. #1
    pegool is offline Member
    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    Arrow 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={(1-2),(2-3), (3,4),(4-7), (3-6), (2-6), (5-6), (1-5)} and also with some demands D=(s,d)={(1-3),(2-3), (4-5). (7-7), (6-4),(2-7)} 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?

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default 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!

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default 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,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default 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!

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,525
    Blog Entries
    7
    Rep Power
    20

    Default Re: graph with its demands

    Quote Originally Posted by kjkrum View Post
    Ah. Are supply and demand related to flow? Sounds like it might be the same properties I learned to call source and sink.
    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,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 16
    Last Post: 03-21-2012, 09:41 AM
  2. Graph in Jsp
    By monika in forum New To Java
    Replies: 0
    Last Post: 04-20-2010, 05:47 PM
  3. ECG Graph
    By bharath333 in forum Java Applets
    Replies: 4
    Last Post: 02-14-2009, 10:26 PM
  4. Bar Graph
    By Zosden in forum Advanced Java
    Replies: 2
    Last Post: 04-28-2008, 06:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •