-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from LucienShui/feature/using_swig
Add swig support
- Loading branch information
Showing
28 changed files
with
377 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
cmake_minimum_required(VERSION 3.17) | ||
project(flow_network) | ||
project(flow-network) | ||
|
||
set(CMAKE_CXX_STANDARD 14) | ||
|
||
add_library(network_flows SHARED flow_network/core/flow-network.cpp flow_network/core/flow-network.h flow_network/core/py-api.h flow_network/core/py-api.cpp) | ||
add_executable(flow-network flow_network/core/minimum_cost_flow.cpp flow_network/core/minimum_cost_flow.h main.cpp flow_network/core/graph.cpp flow_network/core/graph.h flow_network/core/maximum_flow.cpp flow_network/core/maximum_flow.h flow_network/core/common.h flow_network/core/base_network.h flow_network/core/base_network.cpp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
recursive-include flow_network/core *.cpp *.h *.cxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
from .clib import Clib | ||
try: | ||
from .core import MaximumFlow as CMaximumFlow | ||
from .core import MinimumCostFlow as CMinimumCostFlow | ||
from .core import BaseNetwork as CBaseNetwork | ||
except ModuleNotFoundError as e: | ||
import sys | ||
""" | ||
在调用 setup.py 的时候需要读取 flow_network.__version__ | ||
于是 flow_network.__init__.py 会被同时调用,然后一直执行到这里 | ||
但在调用 setup.py 的时候 core.i 还没被编译成 _core | ||
所以在这里 mock 一些 _core 里面的对象,否则会报错 | ||
""" | ||
if sys.argv[0] == 'setup.py': | ||
CMaximumFlow = CMinimumCostFlow = CBaseNetwork = None | ||
else: | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "base_network.h" | ||
|
||
namespace flow_network { | ||
BaseNetwork::BaseNetwork(int n) : dist(new int[n]), n(n), graph(n) {} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef FLOW_NETWORK_BASE_NETWORK_H | ||
#define FLOW_NETWORK_BASE_NETWORK_H | ||
|
||
#include "graph.h" | ||
|
||
namespace flow_network { | ||
|
||
struct BaseNetwork { | ||
int *dist, n; | ||
Graph graph; | ||
|
||
explicit BaseNetwork(int n); | ||
}; | ||
} | ||
|
||
#endif //FLOW_NETWORK_BASE_NETWORK_H |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef FLOW_NETWORK_COMMON_H | ||
#define FLOW_NETWORK_COMMON_H | ||
|
||
namespace flow_network { | ||
|
||
static int INF = 0x3f3f3f3f; | ||
} | ||
|
||
#endif //FLOW_NETWORK_COMMON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
%module core | ||
|
||
%include "std_vector.i" | ||
%include "std_pair.i" | ||
|
||
%{ | ||
|
||
#include "common.h" | ||
#include "graph.h" | ||
#include "base_network.h" | ||
#include "maximum_flow.h" | ||
#include "minimum_cost_flow.h" | ||
|
||
%} | ||
|
||
%template(EdgeVector) std::vector<flow_network::Edge>; | ||
%template(IntVector) std::vector<int>; | ||
%template(IntIntPair) std::pair<int, int>; | ||
|
||
%include "common.h" | ||
%include "graph.h" | ||
%include "base_network.h" | ||
%include "maximum_flow.h" | ||
%include "minimum_cost_flow.h" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.