Skip to content

Instantly share code, notes, and snippets.

@dharmatech
Last active August 29, 2015 14:14
Show Gist options
  • Save dharmatech/ac20616c111547291506 to your computer and use it in GitHub Desktop.
Save dharmatech/ac20616c111547291506 to your computer and use it in GitHub Desktop.
static IEnumerable<Node> Out(this Node node, Label label)
{ return node.Outgoing.Where(rel => rel.Label == label).Select(rel => rel.B); }
static IEnumerable<Node> In(this Node node, Label label)
{ return node.Incoming.Where(rel => rel.Label == label).Select(rel => rel.A); }
var admin = Ben;
foreach (var grp in admin.Out(MEMBER_OF))
foreach(var parent in grp.Out(ALLOWED_INHERIT))
{
var children = new List<Node>();
children.Add(parent);
foreach (var child_1 in parent.In(CHILD_OF))
{
children.Add(child_1);
foreach (var child_2 in child_1.In(CHILD_OF))
{
children.Add(child_2);
foreach (var child_3 in child_2.In(CHILD_OF))
children.Add(child_3);
}
}
foreach (var child in children)
foreach (var emp in child.In(WORKS_FOR))
foreach (var acc in emp.Out(HAS_ACCOUNT))
Console.WriteLine("{0, -10} {1, -10} {2, -10} {3, -10} {4, -10} {5, -10}",
admin.Title, grp.Title, parent.Title, child.Title, emp.Title, acc.Title);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment