Example #1
0
        private void AppendEdgesMerged()
        {
            // keep track of the transitions that are already processed
            // this is needed because duplicate are created when looking for a transition from both its origin and target node
            //HashSet<OriginTargetAnnotation> processedTransitions = new HashSet<OriginTargetAnnotation>();
            Dictionary <OriginTarget, StringBuilder> transitionLabels = new Dictionary <OriginTarget, StringBuilder>();

            foreach (KeyValuePair <IVertex, long> pair in nodeIdTable)
            {
                foreach (IEdge edge in pair.Key.Links.Where(l => l.GetLinkedObjects()[0].Equals(pair.Key)))
                {
                    Annotation annotation = graph.GetAnnotations(edge).First();

                    OriginTarget ot = new OriginTarget()
                    {
                        Origin = edge.GetLinkedObjects()[0] as IVertex,
                        Target = edge.GetLinkedObjects()[1] as IVertex,
                    };
                    //OriginTargetAnnotation ota = new OriginTargetAnnotation()
                    //{
                    //    Origin = edge.GetLinkedObjects()[0] as IVertex,
                    //    Target = edge.GetLinkedObjects()[1] as IVertex,
                    //    Label = new ComparableAnnotation() { Namespace = annotation.Namespace, Key = annotation.Key, Value = annotation.Value }
                    //};

                    //if (processedTransitions.Contains(ota))
                    //    continue;

                    string label = $"{annotation.Key}:{annotation.Value}";
                    if (transitionLabels.ContainsKey(ot))
                    {
                        transitionLabels[ot].Append($",{label}");
                    }
                    else
                    {
                        transitionLabels.Add(ot, new StringBuilder(label));
                    }

                    //processedTransitions.Add(ota);
                }
            }
            foreach (KeyValuePair <OriginTarget, StringBuilder> entry in transitionLabels)
            {
                var ot = entry.Key;
                dotFile.AppendLine($"{GenerateNodeName(ot.Origin)} ->  {GenerateNodeName(ot.Target)}[label=\"{entry.Value.ToString()}\"];");
            }
        }
Example #2
0
            public override bool Equals(object obj)
            {
                OriginTarget ot = obj as OriginTarget;

                return(this.GetHashCode() == ot.GetHashCode());
            }