gonum.org/v1/gonum@v0.14.0/graph/topo/common_test.go (about)

     1  // Copyright ©2015 The Gonum Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package topo
     6  
     7  // batageljZaversnikGraph is the example graph from
     8  // figure 1 of http://arxiv.org/abs/cs/0310049v1
     9  var batageljZaversnikGraph = []intset{
    10  	0: nil,
    11  
    12  	1: linksTo(2, 3),
    13  	2: linksTo(4),
    14  	3: linksTo(4),
    15  	4: linksTo(5),
    16  	5: nil,
    17  
    18  	6:  linksTo(7, 8, 14),
    19  	7:  linksTo(8, 11, 12, 14),
    20  	8:  linksTo(14),
    21  	9:  linksTo(11),
    22  	10: linksTo(11),
    23  	11: linksTo(12),
    24  	12: linksTo(18),
    25  	13: linksTo(14, 15),
    26  	14: linksTo(15, 17),
    27  	15: linksTo(16, 17),
    28  	16: nil,
    29  	17: linksTo(18, 19, 20),
    30  	18: linksTo(19, 20),
    31  	19: linksTo(20),
    32  	20: nil,
    33  }
    34  
    35  // intset is an integer set.
    36  type intset map[int64]struct{}
    37  
    38  func linksTo(i ...int64) intset {
    39  	if len(i) == 0 {
    40  		return nil
    41  	}
    42  	s := make(intset)
    43  	for _, v := range i {
    44  		s[v] = struct{}{}
    45  	}
    46  	return s
    47  }