Minimum Spanning Tree for Computer Network Design (netsle05)

/*************************************************************************/
/*                                                                       */
/*          S A S   S A M P L E   L I B R A R Y                          */
/*                                                                       */
/*    NAME: netsle05                                                     */
/*   TITLE: Minimum Spanning Tree for Computer Network Design (netsle05) */
/* PRODUCT: OR                                                           */
/*  SYSTEM: ALL                                                          */
/*    KEYS: OR                                                           */
/*   PROCS: OPTMODEL, PRINT                                              */
/*    DATA:                                                              */
/*                                                                       */
/* SUPPORT:                             UPDATE:                          */
/*     REF:                                                              */
/*    MISC: Example 5 from the network solver documentation.             */
/*                                                                       */
/*************************************************************************/

data LinkSetInCompNet;
   input from $ to $ weight @@;
   datalines;
A B 1.0  A C 1.0  A D 1.5  B C 2.0  B D 4.0
B E 3.0  C D 3.0  C F 3.0  C H 4.0  D E 1.5
D F 3.0  D G 4.0  E F 1.0  E G 1.0  F G 2.0
F H 4.0  H I 1.0  I J 1.0
;

proc optmodel;
   set<str,str> LINKS;
   num weight{LINKS};
   read data LinkSetInCompNet into LINKS=[from to] weight;
   set<str,str> FOREST;

   solve with NETWORK /
      links       = (weight=weight)
      minspantree
      out         = (forest=FOREST)
   ;

   put FOREST;
   put (sum {<i,j> in FOREST} weight[i,j]);
   create data MinSpanTree from [from to]=FOREST weight;
quit;

proc print data=MinSpanTree noobs label;
   sum weight;
run;