Traversal to inner nodes of a hyperedge

29 views
Skip to first unread message

Moditha Hewasinghage

unread,
Apr 4, 2018, 6:55:23 AM4/4/18
to HyperGraphDB
Hi,
I am new to hypergraphdb and is interested in using it in my  PhD studies. But i seem to encounter some issues.
I am trying to get a path from a hyperedge to an inner element. But it doesn't seem to be working. I have attached a code snippet here to explain the problem. Basically, i would like to know the path from root to target[2] for example but i am getting null as the result same with root,x .Am I doing something wrong ? Any help would be appriciated


HyperGraph graph = new HyperGraph("C:\\hyper\\test");
        
        int n = 4;
        HGHandle[] target = new HGHandle[n];
        for (int i=0; i<n; i++) {
            target[i] = graph.add(new Integer(i));
        }
        
        HGHandle y = graph.add(new HGPlainLink(target[0], target[1]));
        HGHandle z = graph.add(new HGPlainLink(target[1], target[2]));
        HGHandle x = graph.add(new HGPlainLink(y, z, target[3]));
        HGHandle root = graph.add(new HGPlainLink(x));
        
        System.out.println(GraphClassics.dijkstra(root, target[2], new SimpleALGenerator(graph)));

Thank you

Borislav Iordanov

unread,
Apr 22, 2018, 4:50:45 PM4/22/18
to hyperg...@googlegroups.com
Hi,

Apologies for such a late response, it is inexcusable :(

The crucial part of your code below is the AL generator. In a structure like the generalized hypergraph we have in HGDB, pretty much anything goes really. In the sense that interpreting when two atoms are related is very much dependent on your application domain model. Is a link related to its targets? In some sense yes, but in another no because it’s the relationship. Depends on what you want. Oftentimes it is more performant to have the HyperGraphDB be polymorphic in a sense so that to represent a classical graph directed edge between two nodes A and B, instead of creating a link [A,B], you could represent A is the link [B]. So a tree for example could be represented with all its nodes being tuples of their children. In that case, for traversal purposes, the adacent nodes to a node will be its targets. 

Back to your code, the SimpleALGenerator  will treat links as edges in the classical sense and their targets as nodes. So your ‘root’ atom is not connected to anything at all. So you should implement the HGALGenerator interface to tell the traversal exactly what adjacent atoms are. There is a TargetSetALGenerator:

That you can use.

Hope this helps,
Boris

--
You received this message because you are subscribed to the Google Groups "HyperGraphDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hypergraphdb...@googlegroups.com.
To post to this group, send email to hyperg...@googlegroups.com.
Visit this group at https://groups.google.com/group/hypergraphdb.
For more options, visit https://groups.google.com/d/optout.
--

"Damn! The world is big!"

-- Heleni Daly
Reply all
Reply to author
Forward
0 new messages