Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
533e4db
refactor(packaging): Remove deprecated test configuration from setup.py
Acture Oct 20, 2025
7d61aa7
style(packaging): Use SPDX license identifier 'BSD-3-Clause'
Acture Oct 20, 2025
a9ef56b
refactor(packaging): Migrate from `setup.py` to `pyproject.toml` and …
Acture Oct 21, 2025
35f8a23
feat(env): Add `.envrc` for automated virtual environment management
Acture Oct 21, 2025
1a2f23f
refactor(codebase): Remove unused imports and improve variable naming…
Acture Oct 21, 2025
130b41f
refactor(cpp_binding): Replace Boost.Python with pybind11 for bindings
Acture Oct 21, 2025
67e6ab5
refactor(project): modernize project structure and update dependencies
Acture Oct 21, 2025
dec852e
refactor(graph): migrate from Boost.Python to pybind11
Acture Oct 21, 2025
070ffdf
refactor(project): remove legacy test and config files, enhance proje…
Acture Oct 21, 2025
9a93dde
chore(tests): remove legacy `nose` dependency
Acture Oct 21, 2025
d51208d
feat(packaging): add optional Graphviz dependency
Acture Oct 21, 2025
9d95287
fix(graphml,gexf): replace deprecated `np.float_` with `np.float64`
Acture Oct 21, 2025
9c0f243
fix(packaging): update Graphviz optional dependency to `pygraphviz>=1…
Acture Oct 21, 2025
37e898e
fix(tests): replace deprecated `DataFrame.append` with `pd.concat`
Acture Oct 21, 2025
6de337d
refactor(readwrite): remove warnings, fix indentation, and clean up p…
Acture Oct 21, 2025
0b346ee
refactor(graph): standardize string formatting and import usage
Acture Oct 21, 2025
9f36249
refactor(core): replace redundant exception handling with `contextlib…
Acture Oct 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[[ -d '.venv' ]] || uv venv
source .venv/bin/activate
69 changes: 0 additions & 69 deletions .flake8

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,4 @@ x64/
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
**/cmake-build-debug
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
23 changes: 23 additions & 0 deletions _cpp_easygraph/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.15)
if(NOT DEFINED SKBUILD_PROJECT_NAME)
set(SKBUILD_PROJECT_NAME "cpp_easygraph_standalone")
endif()

project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(PYBIND11_FINDPYTHON ON)
find_package(pybind11 CONFIG REQUIRED)

file(GLOB_RECURSE EASYGRAPH_SOURCES "src/*.cpp")


pybind11_add_module(cpp_easygraph MODULE ${EASYGRAPH_SOURCES})

target_include_directories(cpp_easygraph PUBLIC "include")

if(SKBUILD)
install(TARGETS cpp_easygraph DESTINATION ${SKBUILD_PROJECT_NAME})
endif ()
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once
#define BOOST_PYTHON_STATIC_LIB

#include "../../common/common.h"

#include "common.h"
#include "graph.h"

class NeighborIterator {
public:
Expand Down Expand Up @@ -32,4 +33,4 @@ typedef struct stackNode {
}
}stack_node;

py::object _biconnected_dfs_record_edges(py::object G, py::object need_components);
py::list _biconnected_dfs_record_edges(Graph& G, bool need_components);
8 changes: 8 additions & 0 deletions _cpp_easygraph/include/cluster.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once


#include "common.h"

py::object clustering(py::object G,
py::object nodes = py::none(),
py::object weight = py::none());
30 changes: 30 additions & 0 deletions _cpp_easygraph/include/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <iostream>
#include <fstream>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <exception>
#include <set>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>

namespace py = pybind11;

using node_t = int;
using weight_t = float;
using node_attr_dict_factory =
std::map<std::string, weight_t>; //(weight_key, value)
using edge_attr_dict_factory =
std::map<std::string, weight_t>; //(weight_key, value)
using node_dict_factory =
std::unordered_map<node_t, node_attr_dict_factory>; //(node, node_attr)
using adj_attr_dict_factory =
std::unordered_map<node_t, edge_attr_dict_factory>; //(out_node, (weight_key, value))
using adj_dict_factory =
std::unordered_map<node_t, adj_attr_dict_factory>; //(node, edge_attr)
17 changes: 17 additions & 0 deletions _cpp_easygraph/include/directed_graph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once


#include "graph.h"
#include "common.h"

struct DiGraph: public Graph
{
DiGraph();
};

void DiGraph__init__(DiGraph &self, py::kwargs kwargs);
py::dict DiGraph_out_degree(const py::object& self, const py::object& weight);
py::dict DiGraph_in_degree(const py::object& self, const py::object& weight);
py::dict DiGraph_degree(const py::object &self,const py::object &weight);
py::object DiGraph_size(const py::object& self, const py::object& weight);
py::object DiGraph_number_of_edges(const py::object &self,const py::object &u,const py::object &v);
15 changes: 15 additions & 0 deletions _cpp_easygraph/include/evaluation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once
#include "common.h"
#include "graph.h"

py::dict constraint(const py::object &G, py::object nodes,
const py::object &weight,
const py::object &n_workers /*未使用但保留签名*/);
py::object effective_size(py::object G, py::object nodes, py::object weight,
py::object n_workers);


py::dict hierarchy(Graph& G,
py::object nodes = py::none(),
py::object weight = py::none(),
py::object n_workers = py::none());
52 changes: 52 additions & 0 deletions _cpp_easygraph/include/graph.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once


#include "common.h"

struct Graph
{
node_dict_factory node;
adj_dict_factory adj;
py::dict node_to_id, id_to_node, graph;
node_t id;
bool dirty_nodes, dirty_adj;
py::object nodes_cache, adj_cache;

Graph();
py::object get_nodes();
py::object get_name();
py::object get_graph();
py::object get_adj();
py::object get_edges();
};

void Graph__init__(Graph &self, py::kwargs kwargs);
py::object Graph__iter__(py::object self);
py::object Graph__len__(const py::object& self);
py::object Graph__contains__(const py::object& self, const py::object& node);
py::object Graph__getitem__(py::object self, py::object node);
py::object Graph_add_node(const py::tuple& args, const py::dict& kwargs);
py::object Graph_add_nodes(Graph& self,const py::list& nodes_for_adding,const py::list& nodes_attr);
void Graph_add_nodes_from(Graph& self, const py::iterable& nodes_for_adding, const py::kwargs& kwargs);
void Graph_remove_node(Graph& self, const py::object& node_to_remove);
void Graph_remove_nodes(Graph& self, const py::sequence& nodes_to_remove);
py::object Graph_number_of_nodes(Graph& self);
bool Graph_has_node(Graph &self, py::object node);
py::object Graph_nbunch_iter(py::object self, py::object nbunch);
void Graph_add_edge(Graph& self, const py::object& u_of_edge, const py::object& v_of_edge, const py::kwargs& kwargs);
void Graph_add_edges(Graph& self, const py::sequence& edges_for_adding, const py::sequence& edges_attr) ;
void Graph_add_edges_from(Graph& self, const py::iterable& ebunch, const py::kwargs& attr);
void Graph_add_edges_from_file(Graph& self, const py::str& file, bool weighted);
py::object Graph_add_weighted_edge(Graph& self, py::object u_of_edge, py::object v_of_edge, weight_t weight);
void Graph_remove_edge(Graph& self, const py::object& u, const py::object& v);
void Graph_remove_edges(Graph& self, const py::sequence& edges_to_remove);
int Graph_number_of_edges(const Graph& self, py::object u = py::none(), py::object v = py::none());
bool Graph_has_edge(const Graph& self, const py::object& u, const py::object& v);
py::object Graph_copy(py::handle self_h);
py::dict Graph_degree(const Graph& self, py::object weight = py::none());
py::list Graph_neighbors(const Graph& self, const py::object& node);
py::object Graph_nodes_subgraph(py::object self, py::list from_nodes);
py::object Graph_ego_subgraph(py::object self, py::object center);
py::object Graph_size(const Graph& G, py::object weight = py::none());
bool Graph_is_directed(const Graph& self);
bool Graph_is_multigraph(const Graph& self);
6 changes: 6 additions & 0 deletions _cpp_easygraph/include/operation.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once


#include "graph.h"

double density(const Graph& G);
13 changes: 13 additions & 0 deletions _cpp_easygraph/include/path.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once


#include "common.h"
#include "graph.h"

py::dict _dijkstra_multisource(const py::object &G,
const py::object &sources,
const py::object &weight,
const py::object &target);
py::dict Floyd(Graph& G);
py::dict Prim(Graph& G);
py::dict Kruskal(Graph& G);
7 changes: 7 additions & 0 deletions _cpp_easygraph/include/utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include "common.h"

py::dict attr_to_dict(const node_attr_dict_factory& attr);
std::string weight_to_string(py::handle weight);
py::object py_sum(const py::object& o);
Loading