2using System.Threading.Tasks;
31 Triple.Subject.Tag =
null;
32 Triple.Predicate.Tag =
null;
33 Triple.Object.Tag =
null;
45 using (IEnumerator<ISemanticTriple> e = Model.GetEnumerator())
49 while (await eAsync.MoveNextAsync())
50 Result.
Add(e.Current);
55 Result.
Add(e.Current);
81 Dictionary<ISemanticElement, int> Nodes =
new Dictionary<ISemanticElement, int>();
94 if (Nodes.TryGetValue(Triple.
Subject, out TraceNr))
95 Triple.Subject.Tag = TraceNr;
99 Triple.Subject.Tag = TraceNr;
100 Nodes[Triple.
Subject] = TraceNr;
101 Connections[TraceNr, TraceNr] =
true;
112 Triple.Object.Tag = TraceNr;
116 if (Nodes.TryGetValue(Triple.
Object, out
int i))
121 Connections[i, TraceNr] =
true;
126 Triple.Object.Tag = TraceNr;
127 Nodes[Triple.
Object] = TraceNr;
142 Connections[TraceNr, TraceNr2] =
true;
148 while (ToCheck.HasFirstItem)
154 T.Subject.Tag = TraceNr;
156 if (Nodes.TryGetValue(T.
Subject, out
int i))
159 Connections[i, TraceNr] =
true;
168 Connections[i, TraceNr] =
true;
174 T.Object.Tag = TraceNr;
177 if (Nodes.TryGetValue(T.
Object, out
int i))
180 Connections[i, TraceNr] =
true;
184 T.Object.Tag = TraceNr;
185 Nodes[T.
Object] = TraceNr;
198 Connections[i, TraceNr] =
true;
203 Dictionary<int, SemanticGraph> GraphByTrace =
new Dictionary<int, SemanticGraph>();
205 while (NrTraces-- > 0)
207 if (!Connections[NrTraces, NrTraces])
210 SortedDictionary<int, bool> Connected =
new SortedDictionary<int, bool>();
211 GetTraces(Connections, NrTraces, Connected);
216 foreach (
int i
in Connected.Keys)
217 GraphByTrace[i] = Graph;
220 int LastTraceNr = -1;
227 if (TraceNr != LastTraceNr)
229 LastTraceNr = TraceNr;
230 LastGraph = GraphByTrace[TraceNr];
233 LastGraph.Add(Triple);
236 return Graphs.ToArray();
239 private static void GetTraces(
SymmetricMatrix<bool> M,
int TraceNr, SortedDictionary<int, bool> Elements)
243 for (i = M.
Size - 1; i >= 0; i--)
247 M[i, TraceNr] =
false;
249 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 ...
A chunked list is a linked list of chunks of objects of type T .
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.