Script does not save vertex properties

<— the following script “script.py” →

#!/home/george/anaconda3/envs/gt/bin/python3.12

from graph_tool.all import *                                                                                                                   
graph_tool.show_config()

g = Graph()                                                                                                                                    
v1 = g.add_vertex()                                                                                                                            
v2 = g.add_vertex()                                                                                                                            
vcolor = g.new_vp("string")
vcolor[v1] = "#1c71d8"
vcolor[v2] = "#2ec27e"
g.list_properties()
g.save("graph.xml", fmt="xml")

← gives output →

(base) [george@unknown04421A0C4C06 GraphTool]$ ./script.py 
version: 2.79 (commit f935ec6a, )
gcc version: 13.3.0
compilation flags: -DBOOST_ALLOW_DEPRECATED_HEADERS -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 -O3 -isystem /home/george/anaconda3/envs/gt/include -march=x86-64-v3 -I/home/george/anaconda3/envs/gt/include -fopenmp -O3 -fvisibility=default -fvisibility-inlines-hidden -Wno-deprecated -Wall -Wextra -ftemplate-backtrace-limit=0 -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -ffunction-sections -pipe -isystem /home/george/anaconda3/envs/gt/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/graph-tool-suite_1729973898271/work=/usr/local/src/conda/graph-tool-base-2.79 -fdebug-prefix-map=/home/george/anaconda3/envs/gt=/usr/local/src/conda-prefix -march=x86-64-v3 -I/home/george/anaconda3/envs/gt/include -std=c++17 -O3 -Wl,-O3 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/george/anaconda3/envs/gt/lib -Wl,-rpath-link,/home/george/anaconda3/envs/gt/lib -L/home/george/anaconda3/envs/gt/lib -L/home/george/anaconda3/envs/gt/lib
install prefix: /home/conda/feedstock_root/build_artifacts/graph-tool-suite_1729973898271/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac
python dir: /home/conda/feedstock_root/build_artifacts/graph-tool-suite_1729973898271/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.12/site-packages
graph filtering: True
openmp: True
uname: Linux unknown04421A0C4C06 5.14.0-529.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Nov 14 14:09:02 UTC 2024 x86_64
(base) [george@unknown04421A0C4C06 Graph_Tool]$ 

← the resulting graph.xml file is →

(base) [george@unknown04421A0C4C06 Graph_Tool]$ cat graph.xml 
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">

  <!-- property keys -->

  <graph id="G" edgedefault="directed" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst">

   <!-- graph properties -->

   <!-- vertices -->
    <node id="n0">
    </node>
    <node id="n1">
    </node>

   <!-- edges -->

  </graph>
</graphml>

property maps are not saved !

output is

version: 2.79 (commit f935ec6a, )
gcc version: 13.3.0
compilation flags: -DBOOST_ALLOW_DEPRECATED_HEADERS -DNDEBUG -DNDEBUG -D_FORTIFY_SOURCE=2 -O3 -isystem /home/george/anaconda3/envs/gt/include -march=x86-64-v3 -I/home/george/anaconda3/envs/gt/include -fopenmp -O3 -fvisibility=default -fvisibility-inlines-hidden -Wno-deprecated -Wall -Wextra -ftemplate-backtrace-limit=0 -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O3 -ffunction-sections -pipe -isystem /home/george/anaconda3/envs/gt/include -fdebug-prefix-map=/home/conda/feedstock_root/build_artifacts/graph-tool-suite_1729973898271/work=/usr/local/src/conda/graph-tool-base-2.79 -fdebug-prefix-map=/home/george/anaconda3/envs/gt=/usr/local/src/conda-prefix -march=x86-64-v3 -I/home/george/anaconda3/envs/gt/include -std=c++17 -O3 -Wl,-O3 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,/home/george/anaconda3/envs/gt/lib -Wl,-rpath-link,/home/george/anaconda3/envs/gt/lib -L/home/george/anaconda3/envs/gt/lib -L/home/george/anaconda3/envs/gt/lib
install prefix: /home/conda/feedstock_root/build_artifacts/graph-tool-suite_1729973898271/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac
python dir: /home/conda/feedstock_root/build_artifacts/graph-tool-suite_1729973898271/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.12/site-packages
graph filtering: True
openmp: True

Have you tried internalizing the vertex property? That should fix it at
least for saving to .gt files

1 Like

Internalizing worked, I can now save and reload graph. -Thanx