Home Automation Systems as a Graph
Originally my home automation system was constructed as a tree: The house contains Floors, Floors contain Rooms, Rooms contain lights and sensors. That worked quite well for a number of years but there was always the issue of doors. Which room is a door in? An easy answer was to put it in both rooms, but now collections of doors like 'Interior Doors' had two copies of every door, whenever one door closed another one closed too!
Since then I've been migrating to a directed graph instead of a tree. The sole relationship used in the tree (representing 'contains') is being replaced with a variety of relationships like 'connected to', 'open to', 'audible from', 'visible from', 'above', 'below', ... that can express more interesting facts about the house.
This complicates the display of the house in the web view. Instead of traversing a tree it needs to perform a breadth-first search of the graph level-by-level using some relationship types but not others. It also complicates navigation as the breadcrumb bar needs to represent the shortest path back up the tree, not necessarily the one you followed to get here.
At this point I didn't have a way to visualize the graph, but recently I connected the graph up to an API and added another page to the Angular.js application for the house. This new page uses d3.js and webcola to render a force-directed graph layout. You can see some of the results here.
As you can see the system is fairly complex. Currently this graph is showing both physical devices and logical devices. I plan to add an option to show just one or the other.