34 if (line_graph ==
nullptr) {
35 LOG(DFATAL) <<
"line_graph must not be NULL";
38 if (line_graph->num_nodes() != 0) {
39 LOG(DFATAL) <<
"line_graph must be empty";
43 using NodeIndex =
typename GraphType::NodeIndex;
44 using ArcIndex =
typename GraphType::ArcIndex;
46 for (
const ArcIndex arc : graph.AllForwardArcs()) {
48 num_arcs += graph.OutDegree(head);
50 line_graph->Reserve(graph.num_arcs(), num_arcs);
51 for (
const ArcIndex arc : graph.AllForwardArcs()) {
53 for (
const ArcIndex outgoing_arc : graph.OutgoingArcs(head)) {
54 line_graph->AddArc(arc, outgoing_arc);