-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodeMapping.cs
37 lines (30 loc) · 1.13 KB
/
NodeMapping.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using QuikGraph;
namespace GraphRewriteEngine
{
public class NodeMapping : Mapping<Node> {
//Empty starting mapping
public NodeMapping() {
M = new Dictionary<Node, Node>();
}
public NodeMapping(Dictionary<Node, Node> m) {
M = new Dictionary<Node, Node>(m);
}
//The matching order index is embedded in the node's index attribute
//creates copy of mapping to return (not altering the original)
public NodeMapping Extend(Node u, Node v) {
NodeMapping extended = new NodeMapping(this.M);
extended.M[u] = v;
return extended;
}
//This could be way better, but suffices for now
public bool Covers(IEnumerable<Node> V) {
return V.Where(v => Covers(v)).Count() == V.Count();
}
public bool Covers(Node v) { //Despite the paper including both D and R, that causes issues
return M.Keys.Contains(v);
}
}
}