Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ocaml 如何定义加权图?_Ocaml - Fatal编程技术网

Ocaml 如何定义加权图?

Ocaml 如何定义加权图?,ocaml,Ocaml,但是,如果要将权重附加到边上,该怎么办 但是,表示图形的最佳方式是什么?为什么不直接添加它呢 A graph in OCaml can be defined in this way type 'a graph = Gr of ('a * 'a) list;; let myGraph = Gr[(1,2);(1,3);(1,4);(2,6);(3,5);(4,6);(6,5);(6,7);(5,4)];; type weight = float (* or whatever *) type '

但是,如果要将权重附加到边上,该怎么办

但是,表示图形的最佳方式是什么?

为什么不直接添加它呢

A graph in OCaml can be defined in this way

type 'a graph = Gr of ('a * 'a) list;;
let myGraph = Gr[(1,2);(1,3);(1,4);(2,6);(3,5);(4,6);(6,5);(6,7);(5,4)];;
type weight = float (* or whatever *)
type 'a graph = Gr of ('a * 'a * weight) list