Commit 2baef404 authored by Marc Duez's avatar Marc Duez

similarityMatrix.cpp : json output similarity matrix

parent 2841edeb
...@@ -165,20 +165,16 @@ ostream &operator<<(ostream &out, const RawOutputSimilarityMatrix &outputMatrix) ...@@ -165,20 +165,16 @@ ostream &operator<<(ostream &out, const RawOutputSimilarityMatrix &outputMatrix)
/*Export a similarity matrix, for the edit distance distribution & DBSCAN algorithm /*Export a similarity matrix, for the edit distance distribution & DBSCAN algorithm
*/ */
JsonArray &operator<<(JsonArray &out, const JsonOutputSimilarityMatrix &outputMatrix) { json &operator<<(json &out, const JsonOutputSimilarityMatrix &outputMatrix) {
SimilarityMatrix &matrix = outputMatrix.matrix; SimilarityMatrix &matrix = outputMatrix.matrix;
out = json::array();
for (int i = 0; i < matrix.size(); i++) { for (int i = 0; i < matrix.size(); i++) {
out[i] = json::array();
for (int j = 0; j < matrix.size(); j++) { for (int j = 0; j < matrix.size(); j++) {
if (i < j) { out[i][j] = fabs(matrix(i,j));
//Creation of an edges objects array, which contains a source objet, a target object, and the length of the distance between them
JsonList lineEdge;
lineEdge.add("source", i);
lineEdge.add("target", j);
//100 - similarity -> distance
lineEdge.add("len", (100 - matrix(i,j)));
out.add(lineEdge);
}
} }
} }
return out; return out;
...@@ -190,16 +186,12 @@ json &operator<<(json &out, const JsonOutputWindowsMatrix &outputMatrix) { ...@@ -190,16 +186,12 @@ json &operator<<(json &out, const JsonOutputWindowsMatrix &outputMatrix) {
SimilarityMatrix &matrix = outputMatrix.matrix; SimilarityMatrix &matrix = outputMatrix.matrix;
out = { out = json::array();
{"index", json::object()}, //index clone id > matrix row/column
{"matrix", json::array()} //2 dimensional array
};
for (int i = 0; i < matrix.size(); i++) { for (int i = 0; i < matrix.size(); i++) {
//out["index"][] = out[i] = json::array();
out["matrix"][i] = json::array();
for (int j = 0; j < matrix.size(); j++) { for (int j = 0; j < matrix.size(); j++) {
out["matrix"][i][j] = fabs(matrix(i,j)); out[i][j] = fabs(matrix(i,j));
} }
} }
return out; return out;
......
...@@ -121,7 +121,7 @@ class JsonOutputWindowsMatrix: public OutputSimilarityMatrix { ...@@ -121,7 +121,7 @@ class JsonOutputWindowsMatrix: public OutputSimilarityMatrix {
ostream &operator<<(ostream &out, const RawOutputSimilarityMatrix &matrix); ostream &operator<<(ostream &out, const RawOutputSimilarityMatrix &matrix);
ostream &operator<<(ostream &out, const HTMLOutputSimilarityMatrix &matrix); ostream &operator<<(ostream &out, const HTMLOutputSimilarityMatrix &matrix);
JsonArray &operator<<(JsonArray &out, const JsonOutputSimilarityMatrix &matrix); json &operator<<(json &out, const JsonOutputSimilarityMatrix &matrix);
json &operator<<(json &out, const JsonOutputWindowsMatrix &matrix); json &operator<<(json &out, const JsonOutputWindowsMatrix &matrix);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment