What is the best library for generating visual object graphs in PHP (or JavaScript) (e.g. for depicting a social network) [closed]

StackOverflow https://stackoverflow.com/questions/1392167

Question

I have a requirement to graphically depict relationships between a set of objects as well as their types in a PHP application. The relatinships would be previously generated. I am only looking for a tool, preferably free, that will display the nodes and their relations.

I am open to PHP or JavaScript or any thing that will work as long as it does not require (preferably) a separate plugin. I think what I am looking for is a little bit similar to Graphviz.

Some of the relationships between objects could be similar to the following. These are for example only.

Sam->(knows)->Mark    /* Relationship is explicitly defined */
Shannon->(may know)->Jennifer     /* Relationship is inferred */
Linda->(is Married to)->Neville   /* Relationship is defined but information is missing (i.e. gender) to determine which node fills which role (i.e. husband, wife) */
Carl->(is Related to)->John /* Relationship is defined but parameters are completely unknown */

Please note that two objects may also share multiple relationships.

Mary->(is Boss)->John
Mary->(is Wife)->John
Mary->(has children with)->John

The graph needs to depict not only the nodes but also their relationship. The graphics library needs to be somewhat interactive so that a node or the relationship can be clicked on to enable some action--such as the lookup (preferably through AJAX) of additional information. (Even more preferable would be to allow the action to occur on mouseover.)

The library to understand the relationships. It only needs to be able to show that there is a relationship and include the appropriate text describing the relationip that is provided when the diagram is generated.

What is the best library to accomplish this task? Even if there is no single library that fully meets the demand, if there is one that comes close but is extensible, that would be great to know too.

Thank you!

Was it helpful?

Solution

You can lay out a visual-representation pretty easily with yUML. For example, if you wanted to point out that "John is married to Mary, and works for Mark" you could do the following:

[John]->(works for)->[Mark]
[John]->(married to)->[Mary]

Which generates the following:

OTHER TIPS

The Bidirectional Interactive Network Visualization library (for Javascript) seems to have the functionality that you are looking for. It is used to draw ontologies and your example looks a bit like an ontology. People have different and sometimes multiple relationships. In addition, the BINViz library offers neat interactivity, is relatively small, and not dependent on other libs.

Graphviz is what I found to be the most advanced advanced library for rendering graphs. There is PHP Integration via Pear. The samples include ones that match your requirenments.

Also see my question that is somewhat related to yours: Programatically generate graphical (ADAPT) models / diagrams of structured data

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top