Skip to content

Add C++ Backend for BFS and Use std::variant for Graph Node Data #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 28, 2025

Conversation

prex03
Copy link
Contributor

@prex03 prex03 commented Jun 14, 2025

  • Added C++ implementations for DFS and BFS to improve traversal performance.
  • Updated graph node data handling to use std::variant for type-safe storage.
  • Adjusted Python bindings to support these backend changes.

self->data_type = DataType::String;
self->data = std::string(str);
} else {
PyErr_SetString(PyExc_TypeError, "Unsupported data type. Must be int, float, str, or None.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other cases set to normal PyObject data type.

@@ -13,7 +13,6 @@ typedef struct {
} AdjacencyMatrixGraphNode;

static void AdjacencyMatrixGraphNode_dealloc(AdjacencyMatrixGraphNode* self){
Py_XDECREF(self->super.data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is PyObject then keep this inside if.

@prex03 prex03 changed the title Add C++ Backend for DFS/BFS and Use std::variant for Graph Node Data Add C++ Backend for BFS and Use std::variant for Graph Node Data Jun 19, 2025
@prex03 prex03 marked this pull request as ready for review June 20, 2025 15:11
@prex03
Copy link
Contributor Author

prex03 commented Jun 28, 2025

Tests for PyObject* type of data for nodes added in test_misc_util.py lines 39 and 47

@czgdp1807 czgdp1807 merged commit e520be3 into codezonediitj:main Jun 28, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants