Skip to content

Commit

Permalink
Solve suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashok12011234 committed Apr 28, 2024
1 parent f79eb72 commit 8fa0f7d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
32 changes: 18 additions & 14 deletions src/query/algorithms/triangles/StreamingTriangles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ limitations under the License.
#include "../../../util/logger/Logger.h"

Logger streaming_triangle_logger;
std::map<long, std::unordered_set<long>> StreamingTriangles::localAdjacenyList;
std::map<std::string, std::map<long, std::unordered_set<long>>> StreamingTriangles::centralAdjacenyList;
std::map<long, std::unordered_set<long>> StreamingTriangles::localAdjacencyList;
std::map<std::string, std::map<long, std::unordered_set<long>>> StreamingTriangles::centralAdjacencyList;

TriangleResult StreamingTriangles::countTriangles(NodeManager* nodeManager, bool returnTriangles) {
std::map<long, std::unordered_set<long>> adjacenyList = nodeManager->getAdjacencyList();
std::map<long, std::unordered_set<long>> adjacencyList = nodeManager->getAdjacencyList();
std::map<long, long> distributionMap = nodeManager->getDistributionMap();

const TriangleResult &result = Triangles::countTriangles(adjacenyList, distributionMap, returnTriangles);
const TriangleResult &result = Triangles::countTriangles(adjacencyList, distributionMap, returnTriangles);

return result;
}
Expand Down Expand Up @@ -174,8 +174,8 @@ NativeStoreTriangleResult StreamingTriangles::countDynamicLocalTriangles(
edges.push_back(std::make_pair(targetNode, sourceNode));
newAdjacencyList[sourceNode].insert(targetNode);
newAdjacencyList[targetNode].insert(sourceNode);
localAdjacenyList[sourceNode].insert(targetNode);
localAdjacenyList[targetNode].insert(sourceNode);
localAdjacencyList[sourceNode].insert(targetNode);
localAdjacencyList[targetNode].insert(sourceNode);
}

for (int i = oldCentralRelationCount + 1; i <= newCentralRelationCount ; i++) {
Expand All @@ -186,13 +186,13 @@ NativeStoreTriangleResult StreamingTriangles::countDynamicLocalTriangles(
edges.push_back(std::make_pair(targetNode, sourceNode));
newAdjacencyList[sourceNode].insert(targetNode);
newAdjacencyList[targetNode].insert(sourceNode);
localAdjacenyList[sourceNode].insert(targetNode);
localAdjacenyList[targetNode].insert(sourceNode);
localAdjacencyList[sourceNode].insert(targetNode);
localAdjacencyList[targetNode].insert(sourceNode);
}

std::map<long, std::unordered_set<long>> adjacenyList = localAdjacenyList;
std::map<long, std::unordered_set<long>> adjacencyList = localAdjacencyList;

long trianglesValue = totalCount(adjacenyList, newAdjacencyList, edges);
long trianglesValue = totalCount(adjacencyList, newAdjacencyList, edges);

nativeStoreTriangleResult.localRelationCount = newLocalRelationCount;
nativeStoreTriangleResult.centralRelationCount = newCentralRelationCount;
Expand All @@ -207,7 +207,11 @@ std::string StreamingTriangles::countDynamicCentralTriangles(
std::vector<std::string> oldCentralRelationCount) {
streaming_triangle_logger.info("###STREAMING TRIANGLE### Dynamic Streaming Central Triangle "
"Counting: Started");
std::string joinedString = partitionIdList[0] + partitionIdList[1] + partitionIdList[2];
std::string joinedString;

Check warning on line 210 in src/query/algorithms/triangles/StreamingTriangles.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/algorithms/triangles/StreamingTriangles.cpp#L210

Added line #L210 was not covered by tests
for (std::string& partitionId : partitionIdList) {
joinedString += partitionId;
}

std::map<long, std::unordered_set<long>> adjacencyList;
std::vector<std::pair<long, long>> edges;
int position = 0;
Expand Down Expand Up @@ -236,12 +240,12 @@ std::string StreamingTriangles::countDynamicCentralTriangles(
long sourceNode = entry.first;
long targetNode = entry.second;

Check warning on line 241 in src/query/algorithms/triangles/StreamingTriangles.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/algorithms/triangles/StreamingTriangles.cpp#L240-L241

Added lines #L240 - L241 were not covered by tests
edges.push_back(entry);
centralAdjacenyList[joinedString][sourceNode].insert(targetNode);
centralAdjacenyList[joinedString][targetNode].insert(sourceNode);
centralAdjacencyList[joinedString][sourceNode].insert(targetNode);
centralAdjacencyList[joinedString][targetNode].insert(sourceNode);
}
}

adjacencyList = centralAdjacenyList[joinedString];
adjacencyList = centralAdjacencyList[joinedString];
std::basic_ostringstream<char> triangleStream;
long count = 0;

Check warning on line 250 in src/query/algorithms/triangles/StreamingTriangles.cpp

View check run for this annotation

Codecov / codecov/patch

src/query/algorithms/triangles/StreamingTriangles.cpp#L250

Added line #L250 was not covered by tests

Expand Down
4 changes: 2 additions & 2 deletions src/query/algorithms/triangles/StreamingTriangles.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ struct NativeStoreTriangleResult {

class StreamingTriangles {
public:
static std::map<long, std::unordered_set<long>> localAdjacenyList;
static std::map<std::string, std::map<long, std::unordered_set<long>>> centralAdjacenyList;
static std::map<long, std::unordered_set<long>> localAdjacencyList;
static std::map<std::string, std::map<long, std::unordered_set<long>>> centralAdjacencyList;
static TriangleResult countTriangles(NodeManager* nodeManager, bool returnTriangles);

static NativeStoreTriangleResult countLocalStreamingTriangles(
Expand Down

0 comments on commit 8fa0f7d

Please sign in to comment.