forked from YaccConstructor/QuickGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSTaggedEdge.cs
More file actions
81 lines (71 loc) · 2.06 KB
/
STaggedEdge.cs
File metadata and controls
81 lines (71 loc) · 2.06 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
71
72
73
74
75
76
77
78
79
80
81
using System;
using System.Diagnostics.Contracts;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace QuickGraph
{
/// <summary>
/// A tagged edge as value type.
/// </summary>
/// <typeparam name="TVertex">type of the vertices</typeparam>
/// <typeparam name="TTag"></typeparam>
#if !SILVERLIGHT
[Serializable]
#endif
[StructLayout(LayoutKind.Auto)]
[DebuggerDisplay("{Source}->{Target}:{Tag}")]
public struct STaggedEdge<TVertex, TTag>
: IEdge<TVertex>
, ITagged<TTag>
{
readonly TVertex source;
readonly TVertex target;
TTag tag;
public STaggedEdge(TVertex source, TVertex target, TTag tag)
{
Contract.Requires(source != null);
Contract.Requires(target != null);
this.source = source;
this.target = target;
this.tag = tag;
this.TagChanged = null;
}
public TVertex Source
{
get { return this.source; }
}
public TVertex Target
{
get { return this.target; }
}
public event EventHandler TagChanged;
void OnTagChanged(EventArgs e)
{
var eh = this.TagChanged;
if (eh != null)
eh(this, e);
}
public TTag Tag
{
get { return this.tag; }
set
{
if (!object.Equals(this.tag, value))
{
this.tag = value;
this.OnTagChanged(EventArgs.Empty);
}
}
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return String.Format("{0}->{1}:{2}", this.Source, this.Target, this.Tag);
}
}
}