public UniverseGraph GenerateDesignGraph(int count) { if (DataSource.Count < count) { ResetDataSource(count); } var result = new UniverseGraph(); var universeObjects = GetUniverseObjects(); Random rand = new Random(); try { var root = new UniverseVertex() { ID = 1, Text = "root", Model = "Root" }; result.AddVertex(root); //Create and add vertices using some DataSource for ID's foreach (var universe in DataSource.Take(count)) { var parent = new UniverseVertex() { ID = universe.ID, Text = universe.Text, Model = universe }; result.AddVertex(parent); result.AddEdge(new UniverseEdge(root, parent, 1) { Text = string.Format("{0} -> {1}", root.Text, parent.Text) }); var thisUniversesObjects = universeObjects.Where(o => o.UniverseId == universe.ID); foreach (var universObject in thisUniversesObjects) { var child = new UniverseVertex() { ID = universObject.Id, Text = universObject.ObjectName, Model = universObject }; result.AddVertex(child); result.AddEdge(new UniverseEdge(parent, child, 1) { Text = string.Format("{0} -> {1}", parent.Text, child.Text) }); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(result); }
private static bool ShouldUpdateIsSelected(UniverseVertex updateTarget, UniverseVertex compareTarget) { return(updateTarget != null && !updateTarget.Equals(compareTarget)); }