Bug: SegFault when calling `size()` method of ukv.Network
### Describe the bug

When calling `size()` method of `ukv.Network` python shutdowns with no exceptions with error `Segmentation fault (core dumped)`. When running script through python debugger in vscode it just unexpectedly shutdowns without any error or message.

### Steps to reproduce

```python
import ukv.umem as ukv

db = ukv.DataBase()
graph = ukv.Network(db, 'graph', 'nodes', 'edges')
graph.add_edge(1, 2, 0)

print(graph.size())
print('finished')
```

### Expected behavior

Script prints number and then `finished` string

### UKV version

v0.7.4

### Operating System

Ubuntu 22.04.1

### Hardware architecture

x86

### Are you using an embedded version?

- [X] I use the embedded version

### Which interface are you using?

Official Python bindings

### Which engine are you using?

UMem

### Contact Details

_No response_

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
diff --git a/python/networkx.cpp b/python/networkx.cpp
index f608e969..e101b90d 100644
--- a/python/networkx.cpp
+++ b/python/networkx.cpp
@@ -561,7 +561,34 @@ void ukv::wrap_networkx(py::module& m) {
         "A DegreeView with the number outgoing edges for each Vertex.");
     g.def(
         "size",
-        [](py_graph_t& g) { return g.relations_attrs.size(); },
+        [](py_graph_t& g, std::string weight) {
+            if (!weight.size())
+                return g.ref().number_of_edges();
+
+            std::size_t size = 0;
+            auto stream = g.ref().edges(ukv_vertex_source_k).throw_or_release().begin();
+            while (!stream.is_end()) {
+                auto edge_ids = stream.edges_batch().edge_ids.immutable();
+                auto attrs = read_attributes(g.relations_attrs, edge_ids, weight.c_str());
+                for (std::size_t i = 0; i != edge_ids.size(); ++i) {
+                    if (attrs[i] && attrs[i].size()) {
+                        std::size_t number = 0;
+                        auto result = std::from_chars((char*)attrs[i].begin(), (char*)attrs[i].end(), number);
+                        if (result.ec == std::errc())
+                            size += number;
+                        else if (result.ec == std::errc::invalid_argument)
+                            throw std::runtime_error("Unsupported Type");
+                        else
+                            throw std::runtime_error("Failed To Read Attribute");
+                    }
+                    else
+                        size += 1;
+                }
+                stream.seek_to_next_batch();
+            }
+            return size;
+        },
+        py::arg("weight") = "",
         "Returns the number of attributed edges.");
     g.def(
         "number_of_edges",
diff --git a/python/tests/networkx_test.py b/python/tests/networkx_test.py
index 82d9947e..f2a0f01a 100644
--- a/python/tests/networkx_test.py
+++ b/python/tests/networkx_test.py
@@ -260,6 +260,23 @@ def test_clear():
     net.clear()
 
 
+def test_size():
+    db = ukv.DataBase()
+    net = ukv.Network(db, 'graph', 'nodes', 'edges')
+    size = 1000
+    weighted_size = 0
+    for node in range(size):
+        net.add_edge(node, node+1, node, weight=node)
+        weighted_size += node
+
+    assert net.size() == size
+    assert net.size(weight='weight') == weighted_size
+
+    net.add_edge(size, size+1, size, weight='str')
+    with pytest.raises(Exception):
+        net.size(weight='weight')
+
+
 def test_nodes_attributes():
     db = ukv.DataBase()
     net = ukv.Network(db, 'graph', 'nodes')
['python/tests/networkx_test.py', 'python/networkx.cpp']