Last active
August 29, 2015 14:14
-
-
Save dharmatech/ac20616c111547291506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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