Create the Transaction Graph

  1. Run the following query in the psql shell to write the edges file to disk.
    \COPY (SELECT keyimage_id, output_id FROM xmr_bigraph_edges) TO '/tmp/fork-nonringct-edges-2530000.txt' WITH DELIMITER ' ';
    
  2. Each row in the fork-nonringct-edges-2530000.txt file represents an edge. The keyimage_id and output_id values that represent the edge are index values from the respective PostgreSQL tables. These index values do not form a contiguous range and can have gaps. But the sparse graph representations we will use work better without gaps in the index ranges.
    • Copy the fork-nonringct-edges-2530000.txt file to the scripts/monero directory.
    • Compile the create_csparse_edges.cpp file located in the scripts/monero directory. Run it with the block height as argument.
      cd scripts/monero
      g++ -O2 create_csparse_edges.cpp 
      ./a.out 2530000 fork-nonringct
      
      The output should look like the following.
      Reading edge file
      Finished reading edge file
      Number of key images: 19443292
      Number of outputs: 20800067
      Number of vertices: 40243359
      Number of edges: 44196439
      Creating keyimage index map
      Finished creating keyimage index map
      Creating output index map
      Finished creating output index map
      Adding edges to graph
      Finished adding edges to graph
      
    • Three output files are created.
      • fork-nonringct-csparse-edges-2530000.txt

        The edges in this file are represented as pairs of indices starting from 0 followed by a 1. This is the CSparse format for representing sparse matrices. The 1 corresponds to the value of the matrix entry. In our case, we use this format to represent sparse bipartite graphs.

      • fork-nonringct-index-keyimageid-map-2530000.txt

        This file has pairs of indices and key image IDs per line. It is to translate the result of the transaction graph analysis back to the key image ID space.

      • fork-nonringct-index-outputid-map-2530000.txt

        This file has pairs of indices and output IDs per line. It is to translate the result of the transaction graph analysis back to the output ID space.