The LAD format is a kind of graph formats; see https://perso.liris.cnrs.fr/christine.solnon/SIP.html

The specific format requirements are as follows:

Each graph is described in a text file. If the graph has $n$ vertices, then the file has $n+1$ lines:

  • The first line gives the number $n$ of vertices.
  • The next n lines give, for each vertex, its number of successor nodes, followed by the list of its successor nodes.

So I try to convert a claw graph (i.e. the complete bipartite graph $K_{1,3}$) as following:

claw0 = CompleteGraph[{1, 3}, VertexLabels -> Automatic]
vn = VertexCount[claw0] (*the number of vertices of claw0.*)

(*relabel vertices, its labels start from 0.*)
claw = VertexReplace[claw0, 
  Thread[VertexList[claw0] -> Range[0, vn - 1]]]
resultList = 
 Join[{{vn}}, Map[{Length[#], Sequence @@ #} &, AdjacencyList[ claw]]]

which gives:

{{4}, {3, 1, 2, 3}, {1, 0}, {1, 0}, {1, 0}}


Export["E:\\claw.txt", resultList, "Table"]


3   1   2   3
1   0
1   0
1   0


Although I have succeeded, I feel like the final part of my code is not good, especially with inserting the degree (i.e. the number of successor nodes) of every vertex in each sublist. I'm not sure if there's a smoother way to handle that part. Also, I'm not certain if Lad format is a standard thing. Is there some ready-made command for this?

  • 1
    $\begingroup$ You could do IndexGraph[claw0, 0] for vertex replace part $\endgroup$
    – halmir
    Dec 11, 2023 at 15:06


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.