Comparison to neo4j

404 views
Skip to first unread message

OG

unread,
Feb 11, 2010, 5:33:14 PM2/11/10
to HyperGraphDB
Hello,

General question from a person who just found out about HyperGraphDB
and who has been watching that seems almost like hype around neo4j:

How does HyperGraphDB compare to neo4j, technically speaking?

Thanks,
Otis
P.S.
Nice Wiki documentation!

Borislav Iordanov

unread,
Feb 11, 2010, 9:51:54 PM2/11/10
to hyperg...@googlegroups.com
Hi Otis,

On Thu, Feb 11, 2010 at 5:33 PM, OG <otis.gos...@gmail.com> wrote:
> Hello,
>
> General question from a person who just found out about HyperGraphDB
> and who has been watching that seems almost like hype around neo4j:
>
> How does HyperGraphDB compare to neo4j, technically speaking?

I can't really comment on the technical merits of neo4j since I
haven't used it. Conceptually/architecturally I think the two are
quite different: neo4j handles standard property graphs and
HyperGraphDB has some generalizations that you don't see in any other
graph database (ability of edges to point n > 0 nodes, ability of
edges to point to other edges, the notion of types and type
constructors integrated at the core of the system). That doesn't make
HyperGraphDB necessarily better, because the extra generality
translates into different storage layout on disk which has
consequences for how you represent and query things. So I would assume
that neo4j would perform better when all you need is classical
property graphs. And I would assume that a more complicated model
would benefit from a direct hypergraph representation, but I can't
back those assumptions with any actual experiments.

HyperGraphDB was originally designed for an AI project (see
http://www.opencog.org) where this sort of generality is warranted.
That said, to me the system doesn't seem complicated to use, but I'm
the last person that can judge that! :) I just posted a blog entry to
show how it qualifies as an OO database
(http://kobrix.blogspot.com/2010/02/is-hypergraphdb-object-oriented.html)
and I would be more curious to play in depth with db4o and see
HyperGraphDB compares to it. I would be also curious to implement a
document-oriented layer and see how it compares to CouchDB/MongoDB.
Should take a couple of days, but I don't have them right now. If
anybody here is willing to take the challenge, I can provide guidance
and support though :)

The only other DB I've heard of that's close to HyperGraphDB's
architecture is the db behind http://www.freebase.com/, also a graph
database and a description is going to be published soon, I'm told.

> Thanks,
> Otis
> P.S.
> Nice Wiki documentation!
>

Thanks! A lot of it is incomplete though...unfortunately for now :(

Best,
Boris

Philippe Denis

unread,
Feb 12, 2010, 5:12:39 AM2/12/10
to HyperGraphDB
I made a comparaison between the both.
I agree with Borisalav (of course..). I think that HyperGrapghDB is to
create a complicated graph and Neo4j is to create a simple graph with
simple type. In HyperGraphDb you can create hierarchical node/link
because you can use your Java class as a node. However in Neo4j, you
can't do this.

The query are similar. I mean that the syntax is the same.

However, I have something annoying when I make my comparison.
Borislav, is it normal that when I create a graph with +/- 20.000
nodes, It take about 6000 secondes? At each time that I add a node, I
make a graph.getTransactionManager().commit(); . Maybe It's not
optimal but in the futur I'll use HyperGraphDD like this...

I f i do the same with Neo4j, it take about 40 secondes..

Could you tell me if this time is normal?

Thanks

Here is my test code :
graph.getTransactionManager().beginTransaction();
String name = "philippe";
HGHandle handleName = graph.add(name);

for (int i = 0; i < 100;i++) {
String current = "currrent" + i;
HGHandle currhandle = graph.add(current);
HGValueLink link = new HGValueLink("rel",handleName);
graph.add(link);

graph.getTransactionManager().commit();
graph.getTransactionManager().beginTransaction();

}

graph.getTransactionManager().commit();

On Feb 12, 3:51 am, Borislav Iordanov <borislav.iorda...@gmail.com>
wrote:
> Hi Otis,


>
> On Thu, Feb 11, 2010 at 5:33 PM, OG <otis.gospodne...@gmail.com> wrote:
> > Hello,
>
> > General question from a person who just found out about HyperGraphDB
> > and who has been watching that seems almost like hype around neo4j:
>
> > How does HyperGraphDB compare to neo4j, technically speaking?
>
> I can't really comment on the technical merits of neo4j since I
> haven't used it. Conceptually/architecturally I think the two are
> quite different: neo4j handles standard property graphs and
> HyperGraphDB has some generalizations that you don't see in any other
> graph database (ability of edges to point n > 0 nodes, ability of
> edges to point to other edges, the notion of types and type
> constructors integrated at the core of the system). That doesn't make
> HyperGraphDB necessarily better, because the extra generality
> translates into different storage layout on disk which has
> consequences for how you represent and query things. So I would assume
> that neo4j would perform better when all you need is classical
> property graphs. And I would assume that a more complicated model
> would benefit from a direct hypergraph representation, but I can't
> back those assumptions with any actual experiments.
>

> HyperGraphDB was originally designed for an AI project (seehttp://www.opencog.org) where this sort of generality is warranted.


> That said, to me the system doesn't seem complicated to use, but I'm
> the last person that can judge that! :) I just posted a blog entry to
> show how it qualifies as an OO database
> (http://kobrix.blogspot.com/2010/02/is-hypergraphdb-object-oriented.html)
> and I would be more curious to play in depth with db4o and see
> HyperGraphDB compares to it. I would be also curious to implement a
> document-oriented layer and see how it compares to CouchDB/MongoDB.
> Should take a couple of days, but I don't have them right now. If
> anybody here is willing to take the challenge, I can provide guidance
> and support though :)
>
> The only other DB I've heard of that's close to HyperGraphDB's

> architecture is the db behindhttp://www.freebase.com/, also a graph

Philippe Denis

unread,
Feb 12, 2010, 5:33:36 AM2/12/10
to HyperGraphDB
Last observation : Does HyperGraphDB have problem with the unicode?

It don't seem because berkley DB supports unicode...

Philippe Denis

unread,
Feb 12, 2010, 6:39:07 AM2/12/10
to HyperGraphDB
Sorry, I made a mistake in my code. You must change the line :

for (int i = 0; i < 100;i++) {

in
for (int i = 0; i < 20000;i++) {

Borislav Iordanov

unread,
Feb 12, 2010, 11:15:25 AM2/12/10
to hyperg...@googlegroups.com
On Fri, Feb 12, 2010 at 5:12 AM, Philippe Denis <ph.d...@gmail.com> wrote:
> I made a comparaison between the both.
> I agree with Borisalav (of course..). I think that HyperGrapghDB is to
> create a complicated graph and Neo4j is to create a simple graph with
> simple type. In HyperGraphDb you can create hierarchical node/link
> because you can use your Java class as a node. However in Neo4j, you
> can't do this.

Yeah, it seems HyperGraphDB has a much reacher API. I found this as
the Neo4J API:

http://api.neo4j.org/current/

Really neat in simplicity, but it doesn't seem like it offers a lot.
In HyperGraphDB we can make any Java object into an atom (node or
link) and you have much more going on in term of querying, access to
low-level storage, ability to plug at nearly any level into the
system. Perhaps this is simply because they decided not to expose some
APIs that they have internally, and wait until people ask for
them....a perfectly valid choice.

> The query are similar. I mean that the syntax is the same.

How do you do queries in neo4j? There is a layer that does indexing
with a Lucene engine, and you can manually create indices and then
query them (get(key) for a single key), but that's not integrated with
the "kernel".., e.g. I don't see from the API how you can do an
intersection (a join) b/w two indices for example, a very common DB
operation.

In HGDB you have indexing and the graph structure fully integrated and
a relatively extensive query API that will automatically use indices
when available like a regular database. Indexing in HGDB is also
automatic - you don't have to manually add stuff to your index, you
just declare it and associate it with an atom type. Also, in HGDB you
can index arbitrary stuff: from one link target to another, from a
target to a parent link, or you can create custom indexers and add
them to the system. The indexers in HGDB are in fact also HyperGraphDB
atoms so you could associate meta data with them via regular HGDB
links, reason about them etc.!

Perhaps I must be missing some APIs in neo4j I think...

> However, I have something annoying when I make my comparison.
> Borislav, is it normal that when I create a graph with +/- 20.000
> nodes, It take about 6000 secondes? At each time that I add a node, I
> make a graph.getTransactionManager().commit();  . Maybe It's not
> optimal but in the futur I'll use HyperGraphDD like this...
>
> I f i do the same with Neo4j, it take about 40 secondes..

Can you send me yuor Neo4J code, I will download and try it. The HGDB
your code takes about 25seconds on my machine (64bit Vista, dual 2.66
GHZ CPU). If you group the transactions in batches of 100 (i.e. you do
your loop 100 iterations in one transaction instead of one
transaction per iteration), it takes about 20s - a performance gain
due to a reduce number of opening and closing of transactions (which
is expensive).

> Could you tell me if this time is normal?

Absolutely not :) But I still want to try your neo4j code here
locally. Neo4J must be faster here because I suspect it has less work
to do as HGDB maintains incidence sets as link indices automatically
and it also never stores duplicate values of primitive types (so every
in graph.add of a String atom, it will first check that this
particular string value is already stored and reuse it if so - this
behavior is customizable, of course, like pretty much everything).

Best,
Boris

--
http://www.kobrix.com - HGDB graph database, Java Scripting IDE, NLP
http://kobrix.blogspot.com - news and rants

"Frozen brains tell no tales."

-- Buckethead

Borislav Iordanov

unread,
Feb 12, 2010, 11:18:42 AM2/12/10
to hyperg...@googlegroups.com
String are stored with the StringType primitive type, it uses the
default encoding for Java which must be unicode. If not, we must fix
it. If you are having problems (you want a different encoding for
example), you can always replace that primitive type with a custom
one, but there shouldn't be a need for that.

> --
> You received this message because you are subscribed to the Google Groups "HyperGraphDB" group.
> To post to this group, send email to hyperg...@googlegroups.com.
> To unsubscribe from this group, send email to hypergraphdb...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hypergraphdb?hl=en.

Philippe Denis

unread,
Feb 12, 2010, 11:28:36 AM2/12/10
to hyperg...@googlegroups.com

Le 12-févr.-10 à 17:15, Borislav Iordanov a écrit :
How do you do queries in neo4j? 

You can do a query with the traverser framework : http://wiki.neo4j.org/content/Traversal#TraversalPosition_objects
Traverser trav = facture.traverse(Order.BREADTH_FIRST, StopEvaluator.END_OF_GRAPH
   ReturnableEvaluator.ALL_BUT_START_NODE,MyRelationshipType.PAY,Direction.OUTGOING);


Can you send me yuor Neo4J code,
I've joined my code...

Thank

Perfomance.java

Borislav Iordanov

unread,
Feb 12, 2010, 11:43:49 AM2/12/10
to hyperg...@googlegroups.com
On Fri, Feb 12, 2010 at 11:28 AM, Philippe Denis <ph.d...@gmail.com> wrote:
>
> Le 12-févr.-10 à 17:15, Borislav Iordanov a écrit :
>
> How do you do queries in neo4j?
>
> You can do a query with the traverser framework
> : http://wiki.neo4j.org/content/Traversal#TraversalPosition_objects
> Traverser trav = facture.traverse(Order.BREADTH_FIRST,
> StopEvaluator.END_OF_GRAPH,
>
> ReturnableEvaluator.ALL_BUT_START_NODE,MyRelationshipType.PAY,Direction.OUTGOING);

Oh, but that's a different thing. Similar sorts of traversals are
supported in HGDB. But traversing the graph is a rather slow an
unnatural way to query for a subset of the nodes.

> Can you send me yuor Neo4J code,
>
> I've joined my code...
> Thank

Thanks

Borislav Iordanov

unread,
Feb 12, 2010, 11:45:47 AM2/12/10
to hyperg...@googlegroups.com
Ah, but that's your HyperGraphDB code. I need your neo4j
equivalent...I'm not proficient in neo4j and it'll save me some time
to compare the two on the same machine :)

Thanks again,
boris

> --
> You received this message because you are subscribed to the Google Groups
> "HyperGraphDB" group.
> To post to this group, send email to hyperg...@googlegroups.com.
> To unsubscribe from this group, send email to
> hypergraphdb...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hypergraphdb?hl=en.
>
>
>
>

--

Ian Holsman

unread,
Feb 12, 2010, 4:47:30 PM2/12/10
to hyperg...@googlegroups.com
what happens if you change a string value.
does it maintain a reference count and do a copy on write, or does it change the value for everyone who is linked to it?

On Feb 13, 2010, at 3:15 AM, Borislav Iordanov wrote:

>
> Absolutely not :) But I still want to try your neo4j code here
> locally. Neo4J must be faster here because I suspect it has less work
> to do as HGDB maintains incidence sets as link indices automatically
> and it also never stores duplicate values of primitive types (so every
> in graph.add of a String atom, it will first check that this
> particular string value is already stored and reuse it if so - this
> behavior is customizable, of course, like pretty much everything).
>
> Best,
> Boris

--
Ian Holsman
I...@Holsman.net

Borislav Iordanov

unread,
Feb 12, 2010, 4:59:31 PM2/12/10
to hyperg...@googlegroups.com
You can't change a string value, it's immutable. It maintains a
reference count, and it deletes the value from storage when the ref
count reaches 0. You can change the value of an atom though, from one
string to another, or even to some different type (e.g. an integer or
a bean, or whatever).

Well, you can actually change the value of a string, but you have to
do write directly at the storage level. And atoms in the cache won't
see the change.

> --
> You received this message because you are subscribed to the Google Groups "HyperGraphDB" group.
> To post to this group, send email to hyperg...@googlegroups.com.
> To unsubscribe from this group, send email to hypergraphdb...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hypergraphdb?hl=en.
>
>

--

Ian Holsman

unread,
Feb 12, 2010, 5:04:08 PM2/12/10
to hyperg...@googlegroups.com
great.
so if they are treated as a 1st class citizen, then I can create links to them.. very-nice... this should make my life easier.

regards
Ian

--
Ian Holsman
I...@Holsman.net

Borislav Iordanov

unread,
Feb 12, 2010, 7:48:12 PM2/12/10
to hyperg...@googlegroups.com
Perhaps I confused you a little bit: values are something managed by
an atom's type. They are not atoms participating in the graph
structure. They form a graph, but a low-level one and you can't create
links to them. You create links between atoms, not their values. A
value is also identified by a UUID and there's an implicit index
between a value and corresponding atoms. If you do:

HGHandle x = graph.add("hello");
HGHandle y = graph.add("hello");

you will have two different atoms that share the same value of type
string. If you do a query:

hg.findAll(graph, hg.eq("hello"))

you will get a list [x,y]. Even though both x and y share the same
underlying value, there's no official API to change it. It may be a
good idea to add such an API, but I'm not sure.

If you want to enforce the property that only 1 atom with the value
"hello" is stored, you have to add your atoms like this:

hg.addUnique(graph, "hello", hg.eq("hello"));

Cheers,
Boris

OG

unread,
Feb 19, 2010, 12:21:01 PM2/19/10
to HyperGraphDB
Boris, thank you very much for the detailed reply!

Otis

On Feb 11, 9:51 pm, Borislav Iordanov <borislav.iorda...@gmail.com>
wrote:
> Hi Otis,


>
> On Thu, Feb 11, 2010 at 5:33 PM, OG <otis.gospodne...@gmail.com> wrote:
> > Hello,
>
> > General question from a person who just found out about HyperGraphDB
> > and who has been watching that seems almost like hype around neo4j:
>
> > How does HyperGraphDB compare to neo4j, technically speaking?
>
> I can't really comment on the technical merits of neo4j since I
> haven't used it. Conceptually/architecturally I think the two are
> quite different: neo4j handles standard property graphs and
> HyperGraphDB has some generalizations that you don't see in any other
> graph database (ability of edges to point n > 0 nodes, ability of
> edges to point to other edges, the notion of types and type
> constructors integrated at the core of the system). That doesn't make
> HyperGraphDB necessarily better, because the extra generality
> translates into different storage layout on disk which has
> consequences for how you represent and query things. So I would assume
> that neo4j would perform better when all you need is classical
> property graphs. And I would assume that a more complicated model
> would benefit from a direct hypergraph representation, but I can't
> back those assumptions with any actual experiments.
>

> HyperGraphDB was originally designed for an AI project (seehttp://www.opencog.org) where this sort of generality is warranted.


> That said, to me the system doesn't seem complicated to use, but I'm
> the last person that can judge that! :) I just posted a blog entry to
> show how it qualifies as an OO database
> (http://kobrix.blogspot.com/2010/02/is-hypergraphdb-object-oriented.html)
> and I would be more curious to play in depth with db4o and see
> HyperGraphDB compares to it. I would be also curious to implement a
> document-oriented layer and see how it compares to CouchDB/MongoDB.
> Should take a couple of days, but I don't have them right now. If
> anybody here is willing to take the challenge, I can provide guidance
> and support though :)
>
> The only other DB I've heard of that's close to HyperGraphDB's

> architecture is the db behindhttp://www.freebase.com/, also a graph

Reply all
Reply to author
Forward
0 new messages