Skip to content

Commit

Permalink
Changed labels of data vertices when outputing to relations
Browse files Browse the repository at this point in the history
  • Loading branch information
AdiHarif committed Oct 4, 2023
1 parent c1b211e commit 56d753c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/output/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@
import * as csv_writer from 'csv-writer'
import { Graph } from '../graph.js'

import { VertexKind } from '../vertex/vertex.js'
import { LiteralVertex, ParameterVertex, SymbolVertex } from '../module_exports.js';

export async function writeRecordsToFiles(graph: Graph, verticesWriter: any, edgesWriter: any) {

const vertices: Array<Array<any>> = [];
const edges: Array<Array<any>> = [];

graph.vertices.forEach(v => {
vertices.push([ v.id, v.kind, v.category, v.label ]);
let value: string;
switch (v.kind) {
case VertexKind.Literal:
value = String((v as LiteralVertex).value);
break;
case VertexKind.Symbol:
value = (v as SymbolVertex).name;
break;
case VertexKind.Parameter:
value = String((v as ParameterVertex).position);
break;
default:
value = v.label;
break;
}
vertices.push([ v.id, v.kind, v.category, value ]);
edges.push(...v.outEdges.map(e=> [ e.source.id, e.target!.id, e.category, e.label ]));
})

Expand Down

0 comments on commit 56d753c

Please sign in to comment.