Live data from Hacker News

Ask HN: I'm trying to represent an entire building as a graph

news.ycombinator.com

1–10 of 30 posts

Ask HN: I'm trying to represent an entire building as a graph

#1
This entire graph would have to represent every entity in the building, including the control nodes. It's an IoT graph, where a node may represent the light switch, connected to a particular desk(also a node). This graph should also show directions from one entity to another. For now, I have a photoshop pipeline which generates a simplified graph from a color coded image, using NetworkX. This is a temporary replacement for when the actual BIM comes along. But the graph remains. Are there any libraries out there that would help me or should I just roll my own system? I'm not sure I would like to add Neo4J to the stack. Storing everything to Postgres seems to work fine. It's the in memory representation that I have problems with.

Re: Ask HN: I'm trying to represent an entire building as a graph

#5
Using Neo4j community edition would certainly make your life easier in terms of the queries you might want to express, but for this amount of data you can get away with postgres, as you observe.

If you want a simple in memory graph modelling library then check out Apache Tinkerpop. Its great.

Re: Ask HN: I'm trying to represent an entire building as a graph

#6
I working with big graphs. Over 1 bln entities & 40 bln edges.

Best open source graph database is ArrangoDB they have master to master cluster. Fastest and best technology for graphs have commercial TigerDB, but you must pay >300k annually.

Networkx is great but loading full model - but for what you doing should be enough. :)

Re: Ask HN: I'm trying to represent an entire building as a graph

#8
A thing to think about: often there are many different graphs you can create to represent the same thing. Each graph representation can focus on or hide different aspects of the real system.

Why are you trying to model the building as a graph? What are the use cases? What operations do you want this data structure to be able to perform efficiently?

It might turn out that a single graph (or any graph) is not the most effective way of modelling an approximation of the real system.

How many nodes and edges will your graphs typically have? python & networkx work okay for bashing out prototype code and may be good enough for MVP or even a large number of releases if your data size is small and the operations you perform on the graph are linear in the graph size (e.g. connectivity checks, traversals)

I've also seen C/C++ codebases get pretty far by rolling their own domain specific graph data structures-- eg define your own node and edge struct types, give each node and edge pointers to the edges/nodes they connect to, hack domain specific fields as necessary onto the structs. Then just implement each graph algorithm as you need it. This may end up in an unmaintainable mess after a few years, but I've seen this work well enough so that the product based on this is worth enough money that there's enough cash to hire software engineers to come clean things up!

Another thing to think about: are your graphs dynamic or static? If they are large and static, there's lots in common between graphs and sparse matrices. You can encode your graphs in memory in CSR or CSC like sparse matrix formats-- no objects, just giant arrays full of indices. This isn't a good idea if your want to dynamically add or remove nodes and edges, but it is memory efficient.

Re: Ask HN: I'm trying to represent an entire building as a graph

#10
post #6

I working with big graphs. Over 1 bln entities & 40 bln edges. Best open source graph database is ArrangoDB they have master to master cluster. Fastest and best technology for graphs have commercial TigerDB, but you must pay >300k annually. Networkx is great but loading full model - but for what you doing should be enough. :)

ArangoDB is fine, but dgraph [0] can scale easily to that size (we have order of magnitude larger graph). In reality, you can use any resilient key/value store and use hexastore [1] as a storage format.

For instance JanusGraph [2] has support for a lot of different backends, built by the old team behind TitanDB.

[0] https://dgraph.io

[1] http://karras.rutgers.edu/hexastore.pdf

[2] https://janusgraph.org

Post reply on HN