1using System.Collections.Generic;
2using System.Threading.Tasks;
30 Triple.Subject.Tag =
null;
31 Triple.Predicate.Tag =
null;
32 Triple.Object.Tag =
null;
44 IEnumerator<ISemanticTriple> e = Model.GetEnumerator();
48 while (await eAsync.MoveNextAsync())
49 Result.
Add(e.Current);
54 Result.
Add(e.Current);
79 Dictionary<ISemanticElement, int> Nodes =
new Dictionary<ISemanticElement, int>();
80 List<SemanticGraph> Graphs =
new List<SemanticGraph>();
81 LinkedList<ISemanticTriple> ToCheck =
new LinkedList<ISemanticTriple>();
92 if (Nodes.TryGetValue(Triple.
Subject, out TraceNr))
93 Triple.Subject.Tag = TraceNr;
97 Triple.Subject.Tag = TraceNr;
98 Nodes[Triple.
Subject] = TraceNr;
99 Connections[TraceNr, TraceNr] =
true;
102 ToCheck.AddLast(Triple);
110 Triple.Object.Tag = TraceNr;
114 if (Nodes.TryGetValue(Triple.
Object, out
int i))
119 Connections[i, TraceNr] =
true;
124 Triple.Object.Tag = TraceNr;
125 Nodes[Triple.
Object] = TraceNr;
140 Connections[TraceNr, TraceNr2] =
true;
146 while (!(ToCheck.First is
null))
149 ToCheck.RemoveFirst();
153 T.Subject.Tag = TraceNr;
155 if (Nodes.TryGetValue(T.
Subject, out
int i))
158 Connections[i, TraceNr] =
true;
167 Connections[i, TraceNr] =
true;
173 T.Object.Tag = TraceNr;
176 if (Nodes.TryGetValue(T.
Object, out
int i))
179 Connections[i, TraceNr] =
true;
183 T.Object.Tag = TraceNr;
184 Nodes[T.
Object] = TraceNr;
197 Connections[i, TraceNr] =
true;
202 Dictionary<int, SemanticGraph> GraphByTrace =
new Dictionary<int, SemanticGraph>();
204 while (NrTraces-- > 0)
206 if (!Connections[NrTraces, NrTraces])
209 SortedDictionary<int, bool> Connected =
new SortedDictionary<int, bool>();
210 GetTraces(Connections, NrTraces, Connected);
215 foreach (
int i
in Connected.Keys)
216 GraphByTrace[i] = Graph;
219 int LastTraceNr = -1;
226 if (TraceNr != LastTraceNr)
228 LastTraceNr = TraceNr;
229 LastGraph = GraphByTrace[TraceNr];
232 LastGraph.Add(Triple);
235 return Graphs.ToArray();
238 private static void GetTraces(
SymmetricMatrix<bool> M,
int TraceNr, SortedDictionary<int, bool> Elements)
242 for (i = M.
Size - 1; i >= 0; i--)
246 M[i, TraceNr] =
false;
248 GetTraces(M, i, Elements);
static async Task< InMemorySemanticCube > Create(ISemanticModel Model)
Creates an in-memory semantic cube from a semantic model.
Contains triples that form a graph.
override void Add(ISemanticTriple Triple)
Adds a triple to the model.
Static class for extracting semantic graph information from semantic models.
static async Task< SemanticGraph > GetGraph(ISemanticModel Model)
Gets a graph from a semantic model.
static async Task< SemanticGraph[]> GetConnectedGraphs(ISemanticModel Model, ISemanticCube Cube)
Gets connected graphs available in a semantic model.
static async Task< SemanticGraph[]> GetConnectedGraphs(ISemanticModel Model)
Gets connected graphs available in a semantic model.
static Task< InMemorySemanticCube > CreateInMemoryCube(ISemanticModel Model)
Creates an in-memory semantic cube from a semantic model.
static void ClearTags(ISemanticModel Model)
Clears any tags set on elements in the model.
Implements a dynamic symmetric matrix.
int Size
Size of Matrix. The size represents both width and height, as a symmetric matrix have the same width ...
Interface for semantic cubes.
object Tag
Property used by processor, to tag information to an element.
bool IsLiteral
If element is a literal.
Interface for semantic models.
Interface for semantic planes.
Interface for semantic triples.
ISemanticElement Object
Object element
ISemanticElement Subject
Subject element
Interface for asynchronous enumerators.