public Edge(MLFGraph graph, short label, Node from, Node to, Group group = null, Edge dualEdge = null) : base(graph, graph.DataSource, delegate(Factorable f) { Edge e = f as Edge; if (graph.BidirectionEdge) { return(e.From.InEdge.Concat(e.To.OutEdge).Cast <Factorable>().ToList()); } else { List <Edge> edges = e.From.InEdge.Concat(e.From.OutEdge).Concat(e.To.InEdge).Concat(e.To.OutEdge).ToList(); edges.RemoveAll(x => x == e); return(edges.Cast <Factorable>().ToList()); } }) { this.Id = graph.AllocateEdgeId(); this.Label = label; this.From = from; this.To = to; this.Group = group; this.Graph = graph; this.DualEdge = dualEdge; from.OutEdge.Add(this); to.InEdge.Add(this); this.Attribute = new Dictionary <int, object>(); }
public Node(MLFGraph graph, Group group = null) : base(graph, graph.DataSource, delegate(Factorable f) { Node v = f as Node; List <Node> nodes = new List <Node>(); foreach (Edge e in v.InEdge) { nodes.Add(e.From); } foreach (Edge e in v.OutEdge) { nodes.Add(e.To); } nodes = nodes.Distinct().ToList(); nodes.Remove(v); return(nodes.Cast <Factorable>().ToList()); }) { this.Id = graph.AllocateNodeId(); this.Group = group; this.Graph = graph; this.InEdge = new List <Edge>(); this.OutEdge = new List <Edge>(); this.Attribute = new Dictionary <int, object>(); }
public Group(MLFGraph graph, short label, List <Node> memberList = null) : base(graph, graph.DataSource, delegate(Factorable f) { Group g = f as Group; List <Group> groups = new List <Group>(); foreach (Edge e in g.MemberEdge) { if (!g.InGroup(e.From)) { groups.Add(e.From.Group); } if (!g.InGroup(e.To)) { groups.Add(e.To.Group); } } groups = groups.Distinct().ToList(); groups.RemoveAll(x => x == null); return(groups.Cast <Factorable>().ToList()); }) { this.Id = graph.AllocateGroupId(); this.Label = label; this.Member = (memberList == null) ? new List <Node>() : memberList; this.MemberEdge = new List <Edge>(); BuildMemberEdge(); this.Graph = graph; this.Attribute = new Dictionary <int, object>(); }
public Factorable(MLFGraph graph, Dataset dataSource, AdjacentFactorable AdjacentMethod) { this.Graph = graph; this.DataSource = dataSource; this.AdjacentMethod = AdjacentMethod; this.FactorDictionary = new Dictionary <int, object>(); this.FactorEnabled = new Dictionary <int, bool>(); this.FactorTypes = new Dictionary <int, FactorType>(); }
public BPGraph(MLFGraph baseGraph) { this.BPNodeLayer = new List <BPUnit <Node> >(); this.BPEdgeLayer = new List <BPUnit <Edge> >(); this.BPGroupLayer = new List <BPUnit <Group> >(); this.Base2BPMapping = new Dictionary <object, object>(); this.BaseGraph = baseGraph; BuildBPGraph(); }
public void SetInvalid() { this.RemoveMember(this.Member); this.Graph = null; }