https://github.com/jexp/graph-wrapper
diverse graph wrappers, for object networks, dom, etc.
https://github.com/jexp/graph-wrapper
Last synced: 5 days ago
JSON representation
diverse graph wrappers, for object networks, dom, etc.
- Host: GitHub
- URL: https://github.com/jexp/graph-wrapper
- Owner: jexp
- Created: 2011-11-25T18:58:24.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-11-25T23:10:58.000Z (over 14 years ago)
- Last Synced: 2025-06-16T02:02:23.958Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 105 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
## purpose
Wrap existing, large in memory object networks behind the Neo4j graph database API's to enable:
* fast traversals
* graph algorithms
* cypher queries
* gremlin expressions
* visualization
* server
## usage
class User {
private String twid;
private Collection tweeted = new ArrayList();
...
}
class Tag {
private String name;
private Collection tagged = new HashSet();
...
}
class Tweet {
private String id;
private String text;
private long date;
private User tweeted;
private Collection tagged = new HashSet();
}
user = new User("mesirii");
neo4j = new Tag("neo");
graphdb = new Tag("graphdb");
tweet1 = user.tweet("tweet1", neo4j);
tweet2 = user.tweet("tweet2", neo4j, graphdb);
tweet3 = user.tweet("tweet3", graphdb);
tweet4 = user.tweet("tweet4", graphdb);
gdb = new ObjectGraphDatabaseService(user);
allTweets = asList(tweet1, tweet2, tweet3,tweet4);
ObjectNode tweetNode = gdb.createNode(user);
Iterable relationships = tweetNode.getRelationships(Direction.OUTGOING, DynamicRelationshipType.withName("tweeted"));
Iterable tweets = tweetNode.getEndNodeObjects(relationships);
assertEquals(allTweets, IteratorUtil.asCollection(tweets));
String query = "start me=node:User(twid={user})
match me-[:tweeted]->tweet-[:tagged]->tag
return count(tweet),tag.name order by tag.name asc";
ExecutionResult result = new ExecutionEngine(gdb).execute(query, map("user", "mesirii"));
## current state
* mostly readonly, some write operations supported
* cypher, traversals, id-lookup, index-lookups work
* no Relationship-Entity support
## ideas
* createNode(type)
* find getNodeById() via traversal not by storing a map
* InstanceIndex which reflects the actual instances
* Relationships for classes with exactly 2 entity-instance fields
* Superclass support ?