Search Unity

Force Directed Graphs

Discussion in 'Made With Unity' started by doombob, Dec 17, 2015.

  1. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    I've developed a force directed graph system for a game I'm working on, and am curious if there is any interest out there in me polishing it up and putting on the asset store? Here's a quick demostration video (showing the editor used to mess with the physics settings until you're happy with them).



    The library is designed to be easy to use but flexible and powerful, for instance, the code used to spawn each node in the video above is:

    Code (CSharp):
    1. nodes.Add(root.SpawnInside(new Thing("Node"), nodePrefab, nodePhysicsSettings)
    2.                     .RepelFromAllSimilarNodes()
    3.                     .WakeUpAllSimilarNodes()
    4.                     .AttractToNode(Util.RandomElement(nodes))
    5.                     .LinkWith(Prefabs.instance.connectionPrefab, 0.25f)
    6.                     .Appear());
    Where the "new Thing("Node")" is the thing the node represents (which can be anything).

    I imagine it being useful for game maps, skill trees, puzzle elements, or in my case, network topologies. It also functions in a 2D mode, which flattens the graph onto a plane and could be useful for other applications.

    I guess I just want to gauge any interest in such a library, to decide it would be work tidying it up for the asset store and pop it up on there for a few bucks :)
     
    Last edited: Dec 17, 2015
    CodeRonnie likes this.
  2. ecompositor

    ecompositor

    Joined:
    Jun 3, 2014
    Posts:
    2
    I am playing with pulling some graph data from graphX into unity and think your library would be a good starting point. I would spend the money if source is included. I plan on using VR to explore graph data
     
  3. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    Source would be included, physics stuff like this can always use a little fine tuning for each use case.
     
  4. ytrew

    ytrew

    Joined:
    Feb 22, 2013
    Posts:
    20
    Looks great, this is something i could use in my current project! I am looking for a way to visualize a large data set. Any plans to add 2d graphs?
     
  5. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    I added 2D graphs, which can be used exclusively, or mixed with with 3D graphs for interesting UI possibilities.

    http://imgur.com/53q13gg

    EDIT:
    Keep in mind the 2D mode is simply a 3D graph projected onto a plane, either defined by a normal or camera facing. It would be fairly trivial to add a pure 2D mode that uses sprites instead of meshes, there may even be some mild performance gains.
     
    Last edited: Dec 30, 2015
  6. ytrew

    ytrew

    Joined:
    Feb 22, 2013
    Posts:
    20
    Nice, could one populate the data at runtime? The data set I have can be static, parsed from a json file, or dynamic based on runtime analysis.

    What is the time line for your project? If it's relatively soon I'll certainty hold off on the visual portion on my project :)
     
  7. rossdaht

    rossdaht

    Joined:
    Jun 11, 2014
    Posts:
    1
    Yes definitely interested!

    How do you input data/ in what format?
     
  8. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    The data is exclusively populated at runtime, as is the requirements for my game. Each use case would need to write a small layer between their parser and the library to generate the graph using static data, but once generated, more nodes can be added at runtime with ease.

    I'm currently finishing off an editor which makes it easy to play with different physics settings and generates .phys (JSON) files which the library can use at runtime. I'm a bit of a perfectionist, but if you need the library in short order, I can forego some of the polish (it's already quite usable).
     
  9. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    The format is up to you, as the nodes are added at runtime. It should be trivial to write a layer that generates nodes based on any kind of file. If the demand is there, I'd be happy to add some generators for some common file types, but to be honest, I don't really know much about any existing standards in this area, as my experience is primarily in games.
     
  10. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    Here's a web demo of the current version of the library. All the work is done on the GPU now for substantial performance improvements. Unfortunately it will not run on OSX currently as they don't support Compute Shaders (Apple has not kept very up to date with OpenGL).

    Also, run this in something other then Chrome, as I'm sure most of you're aware, Chrome doesn't like Unity's web player any more, and WebGL hasn't caught up with Compute Shaders yet.

    http://www.klaxon.eclipse.co.uk/ForceGraph1/

    Any feedback would be appreciated, or if anyone encounters any problems with it.

    I'm currently working on documentation then I will start the process of submitting it to the asset store.
     
  11. lexacutable

    lexacutable

    Joined:
    Jan 24, 2014
    Posts:
    8
    Would just like to say this looks awesome, and I'm looking forward to seeing it on the Asset Store! I'd like to visualise the node graph of a choose-your-own-adventure type game I'm working on. I'm doing that with Python and GraphViz currently, and it's not that great :p
     
  12. morandd

    morandd

    Joined:
    Feb 22, 2016
    Posts:
    1
    yes please, I would buy it immediately.

    also, please add a cutoff time after which the layout freezes. While the slow floating looks cool, it also absolutely eats CPU+battery :)
     
    si_fab likes this.
  13. JermyAker

    JermyAker

    Joined:
    Aug 4, 2014
    Posts:
    17
    Is this going to be offered on the Asset Store?
    If not, would you be willing to share some of the layout concepts? Thanks!
     
  14. si_fab

    si_fab

    Joined:
    Mar 8, 2016
    Posts:
    1
  15. amanmathur

    amanmathur

    Joined:
    Jul 17, 2013
    Posts:
    5
    This seems amazing! When are you launching this on the Asset Store?
     
  16. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    I'm afraid the library I've been working on has been caught up in a data visualization start-up company, so as much as I wanted to release it on the Asset Store, it's looking unlikely this will happen any time soon :( I'm sorry everyone.

    All I can do is suggest you read up on "force directed graphs", "constraint relaxation" (as opposed to using spring forces, which are much less stable at low frame rates), "verlet integration", "compute shaders" or "OpenCL" (which is more cross-platform), and perhaps "barnes-hut simulation" and "oct-trees" (mostly if you take a CPU approach, less important with GPU approaches). The trick for large graphs is getting as much of the math running on the GPU.

    Good luck if you decide to have a go yourselves!
     
    freekpixels likes this.
  17. IARI

    IARI

    Joined:
    May 8, 2014
    Posts:
    70
    Oh no, I could really have used that :)
    - just out of curiousity, where would that startup be located? ^^
     
  18. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    We're based in Vancouver, Canada.
     
  19. BradFichter

    BradFichter

    Joined:
    Nov 17, 2016
    Posts:
    5
  20. jimmy6dof

    jimmy6dof

    Joined:
    Nov 7, 2022
    Posts:
    5
    Hey @doombob this is an old thread but I just wanted to see if all that IP lockup story is still a thing or if you could resuscitate this or share a little more I am on a small team and this is exactly the wheel we are trying to re-invent. Anyhow, thanks for the pointers we see the same problem using Springs too !
     
  21. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    Hit me up with a DM :)
     
  22. doombob

    doombob

    Joined:
    Jan 25, 2014
    Posts:
    23
    The IP on this has pretty much fallen back to me now if anyone else is interested too
     
  23. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,697
  24. hutchid6

    hutchid6

    Joined:
    Feb 12, 2019
    Posts:
    2
    I'm very interested! Would definitely purchase as an asset