Repository navigation
Expand file tree
/
Copy pathLEdge.cs
More file actions
70 lines (54 loc) · 1.87 KB
/
Copy pathLEdge.cs
File metadata and controls
70 lines (54 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using QuikGraph;
namespace GraphRewriteEngine
{
public class LEdge : IEdge<Node>, IEquatable<LEdge>, ITagged<string>, ICloneable { //add IComparable
public string Tag { get; set; }
public Node Source { get; set; }
public Node Target { get; set; }
public LEdge(Node a, Node b) { //check if this ordering makes this edge "unordered"
if (a.Index < b.Index) {
this.Source = a;
this.Target = b;
}
else {
this.Source = b;
this.Target = a;
}
this.Tag = "";
}
public LEdge(Node a, Node b, string tag) {
this.Source = a;
this.Target = b;
this.Tag = tag;
}
public override int GetHashCode()
{
return (this.Source.Index, this.Source.Index).GetHashCode();
}
public override bool Equals(object obj)
{
return this.Equals(obj as LEdge);
}
public override string ToString()
{
return $"e({this.Source.ToString()}, {this.Target.ToString()}).L:{this.Tag}";
}
//Should this be one-sided? Does this two-sided implementation mess things up?
public bool Equals (LEdge e) {
if (e == null) {
return false;
}
return this.Source.Equals(e.Source) && this.Target.Equals(e.Target);
//|| this.Source.Equals(e.Target) && this.Target.Equals(e.Source);
}
public object Clone() {
return new LEdge(this.Source.Clone() as Node, this.Target.Clone() as Node, this.Tag);
}
public bool IsEquivalent(LEdge e) {
return this.Tag.Equals(e.Tag);
}
public event EventHandler TagChanged;
}
}