Generating n-partite graphs

2008-03-25
2013-05-29
  • Chris Koerner

    Chris Koerner - 2008-03-25

    Hi,

    I was wondering what the best way is to generate a n-partite graph (e.g. n = 2 or n =3 ). Is there an example available for JUNG 2.0?

    Kind regards,
    chris

     
    • Joshua O'Madadhain

      Chris:

      JUNG 2.0 does not yet have support for k-partite graphs; the mechanisms that were used for this purpose in JUNG 1.x don't have direct analogues in JUNG 2.0.

      I'm not sure if you mean "generate" or "visualize" or "represent".  If you can tell us a bit more about what you need, we can give you more specific guidance.

      Joshua

       
    • Chris Koerner

      Chris Koerner - 2008-03-25

      Hi Joshua,

      Thanks for the quick response.

      I need to generate a 3-mode graph from data I have acquired. Is there a simple example for KPartiteSparseGraph?

      Chris

       
      • Joshua O'Madadhain

        OK, so by "generate" you mean "build".  Got it.

        What I would suggest that you do is this: create a class that extends one of the existing implementations (say UndirectedSparseGraph if you want an undirected-only graph that doesn't accept parallel edges).

        You'll need to do the following to make this new class k-partite:

        (1) Provide some way of determining which vertices go in each partition.  I'd recommend providing a Collection of Predicates in the constructor, as we do in JUNG 1.x.
        (2) Override addEdge() so that it checks to see whether an edge's endpoints are legal (i.e., in different partitions) before calling super.addEdge().

        Optionally--if you need it--provide some way of retrieving the vertices for a specified partition.
        (Also, depending on how your partitions are defined, you might need to override addVertex() if it's possible to supply a vertex that doesn't fit in any of them.)

        At some point I'll probably throw in a class or two that does this, but it should really be very simple.

        Joshua

         
        • Chris Koerner

          Chris Koerner - 2008-03-25

          Hi Joshua,

          Do you recommend using JUNG 2.0 to do so or 1.7.6?

          Chris

           
          • Joshua O'Madadhain

            Chris:

            We don't particularly recommend JUNG 1.x for anything at this point.  If there's something from 1.x that you need that 2.0 doesn't have yet, let us know and we'll try to help you out.  In our opinion, JUNG 2.0 is a much better design overall, and is continuing to improve, whereas anything that's wrong with 1.x will stay wrong at this point. 

            So: go with JUNG 2.0. :)

            Joshua

             
    • Chris Koerner

      Chris Koerner - 2008-03-25

      Joshua:

      Thanks for the advice! :)

      Chris

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks