MCPcopy Create free account
hub / github.com/TuGraph-family/tugraph-db / register_gemini_adapter

Function register_gemini_adapter

src/python/python_api.cpp:1974–2004  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1972};
1973
1974void register_gemini_adapter(pybind11::module& m) {
1975 pybind11::class_<EdgeListWriter>(m, "EdgeListWriter")
1976 .def(pybind11::init<const std::string&, bool>(),
1977 "Open a new file for writing out a list of edges.\n"
1978 "`binary` denotes whether the output should be in binary (true) or "
1979 "text (false) format.",
1980 pybind11::arg("path"), pybind11::arg("binary") = true,
1981 pybind11::call_guard<SignalsGuard>())
1982 .def("EmitEdge", &EdgeListWriter::EmitEdge, "Append an edge to the opened file.",
1983 pybind11::arg("src"), pybind11::arg("dst"),
1984 pybind11::call_guard<SignalsGuard>())
1985 .def(
1986 "EmitWeightedEdge",
1987 [](EdgeListWriter& self, size_t src, size_t dst, const pybind11::object& weight) {
1988 if (pybind11::isinstance<pybind11::float_>(weight)) {
1989 self.EmitWeightedEdge<float>(src, dst, weight.cast<float>());
1990 } else if (pybind11::isinstance<pybind11::int_>(weight)) {
1991 self.EmitWeightedEdge<int>(src, dst, weight.cast<int>());
1992 } else if (pybind11::isinstance<pybind11::bool_>(weight)) {
1993 self.EmitWeightedEdge<bool>(src, dst, weight.cast<bool>());
1994 } else {
1995 throw std::runtime_error("Not supported weight type.");
1996 }
1997 },
1998 "Append a weighted edge to the opened file.\n"
1999 "Only {bool, int, float} weights are supported.",
2000 pybind11::arg("src"), pybind11::arg("dst"), pybind11::arg("weight"),
2001 pybind11::call_guard<SignalsGuard>())
2002 .def("Close", &EdgeListWriter::Close, "Close the edge list file.",
2003 pybind11::call_guard<SignalsGuard>());
2004}
2005
2006// Declare the python api with pybind11
2007PYBIND11_MODULE(liblgraph_python_api, m) {

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected