为什么igraph中eigen_centrality函数的结果每次执行时都不同

时间:2020-09-20 08:31:18

标签: r igraph

我想在我的交易数据网络上计算特征集中度。但是,每次运行igraph中的eigen_centrality函数时,它都会为节点创建不同的结果。

代码如下:

relations <- data.frame(from = data$from, 
                        to = data$to)
network <- graph_from_data_frame(relations, directed = T)

E(network)$weight <- log(data$amount + 1.1) # weight of the edges

V(network)$eigenCentrality <- eigen_centrality(network, scale = TRUE)$vector

network_data <- igraph::as_data_frame(network, what = "vertices")
head(network_data) 

上面的代码的结果每次运行都会产生不同的结果。

运行结果:

        name    eigenCentrality
        <chr>   <dbl>
5695    5695    0.00000000000000004061352       
9379    9379    0.00000000000000001507577       
8170    8170    0.00000000000000002865109       
9845    9845    0.00000000000000000000000       
9640    9640    0.00000000000000000000000       
5815    5815    0.00000000000000000000000        

另一次运行的结果:

        name    eigenCentrality
        <chr>   <dbl>
5695    5695    0.0000000000000000000000        
9379    9379    0.0000000000000000000000        
8170    8170    0.0000000000000000000000        
9845    9845    0.0000000000000002674064        
9640    9640    0.0000000000000000000000        
5815    5815    0.0000000000000011516567    

可能是什么原因造成的?

可复制的示例:

structure(list(id = 0:499, from = c("5695", "9379", "8170", "9845", 
"9640", "5815", "8583", "8314", "8865", "6530", "9155", "7536", 
"7085", "5829", "9606", "6795", "5573", "7874", "9409", "5454", 
"9318", "8763", "9030", "9280", "5517", "9387", "9810", "9056", 
"7300", "7313", "7518", "5601", "7549", "7841", "8888", "5808", 
"9545", "9460", "8053", "6615", "8846", "7280", "8265", "6934", 
"8930", "6917", "7889", "7653", "6262", "7222", "7907", "6203", 
"9098", "7278", "6312", "8844", "8822", "9742", "8687", "9174", 
"5939", "7424", "6797", "7564", "8671", "6415", "5610", "6052", 
"9152", "7568", "5503", "7869", "7148", "6686", "6223", "7343", 
"8990", "8027", "5673", "6718", "5858", "7001", "9529", "8708", 
"7603", "7468", "7601", "9868", "5755", "9655", "8321", "9110", 
"5726", "6393", "7425", "5803", "6268", "9723", "7682", "6839", 
"7063", "8046", "9558", "8628", "7719", "7754", "6292", "6306", 
"9069", "6329", "8238", "9793", "8178", "5538", "8305", "7227", 
"9207", "9694", "6194", "7559", "5373", "8235", "8280", "6252", 
"6646", "5781", "5568", "6234", "5588", "6015", "6253", "5400", 
"5954", "8518", "6829", "6660", "7210", "6351", "6147", "5907", 
"6504", "7344", "7584", "7989", "7265", "7207", "9620", "6022", 
"6733", "6210", "8631", "6222", "7070", "7313", "9524", "5640", 
"5649", "9291", "7617", "8727", "9152", "6794", "6502", "7259", 
"9723", "5621", "7055", "7151", "8594", "8980", "7264", "6526", 
"8781", "7984", "6114", "9408", "9115", "6140", "8537", "7370", 
"7744", "8551", "5562", "6354", "7783", "5443", "9161", "5668", 
"9249", "8422", "5409", "9216", "7253", "5921", "8689", "7869", 
"6329", "5836", "9669", "8708", "6359", "8239", "9021", "8469", 
"9135", "6043", "5776", "6770", "7725", "5769", "7502", "6284", 
"9811", "6830", "7047", "5608", "8282", "9047", "8708", "8768", 
"9398", "8532", "9048", "7195", "7812", "7568", "7528", "5957", 
"8233", "6312", "7039", "6874", "7047", "8390", "9843", "8906", 
"5952", "6772", "5774", "5773", "5816", "7664", "6600", "7093", 
"6454", "6487", "6934", "5585", "6358", "5876", "8266", "6794", 
"6361", "6799", "7839", "8047", "6390", "8423", "7247", "7534", 
"8870", "8756", "8880", "9772", "6989", "6248", "9161", "6374", 
"7893", "8228", "6514", "9135", "7974", "8395", "8361", "9027", 
"8456", "6616", "7035", "9047", "8532", "7488", "7382", "6600", 
"6784", "9597", "9075", "6228", "8708", "8736", "6442", "9137", 
"5573", "8168", "9803", "7650", "7290", "6410", "5409", "9450", 
"9201", "7728", "7049", "6986", "9084", "7955", "8336", "9457", 
"9676", "8078", "6540", "8757", "7084", "9811", "9161", "7492", 
"5566", "8872", "5931", "9161", "5722", "8502", "6836", "6648", 
"9696", "9498", "7247", "8317", "8389", "6375", "7109", "8304", 
"6463", "8894", "8741", "9719", "8963", "5915", "7336", "7802", 
"8374", "5922", "7680", "8598", "6634", "6765", "7880", "9855", 
"7653", "8683", "8640", "8853", "9277", "8105", "9819", "8472", 
"8713", "6509", "7503", "7069", "8787", "9251", "9744", "8912", 
"6502", "7614", "6669", "7603", "6749", "7860", "9589", "5715", 
"8130", "6143", "6129", "8937", "9075", "8660", "6883", "8599", 
"6634", "9723", "7494", "6417", "5650", "9613", "7021", "7996", 
"5784", "5885", "7390", "7247", "6230", "9398", "7495", "8512", 
"8456", "9684", "9802", "5418", "8668", "5605", "9803", "9813", 
"8206", "9398", "6022", "9251", "8783", "8723", "8713", "7321", 
"9610", "6334", "5866", "7792", "8422", "5562", "5512", "7711", 
"9632", "5896", "8472", "8945", "8982", "7047", "7057", "8809", 
"9630", "6479", "5433", "8933", "9839", "8735", "6153", "6042", 
"7899", "9111", "7332", "5473", "8869", "5418", "7770", "6883", 
"9803", "7598", "5831", "9750", "6099", "8982", "5433", "7049", 
"7293", "8945", "6551", "8763", "9228", "8739", "9315", "5644", 
"7718", "8008", "8239", "6794", "8499", "7854", "8041", "9617", 
"9525", "8423", "5576", "9545", "6997", "6600", "6138", "9657", 
"8266", "7631", "8785", "8945", "6375", "8615", "7271", "7326", 
"9652", "5999", "5976", "9392", "8118", "9580", "9046", "7517", 
"6407", "8934", "7577", "6510", "5727", "9840", "9350", "9369"
), to = c("7468", "6213", "7517", "6143", "6254", "6669", "6934", 
"9240", "6374", "6143", "8105", "9131", "9770", "6217", "6454", 
"6375", "9565", "9723", "8336", "8078", "9202", "9333", "7518", 
"6503", "9839", "8472", "6673", "8671", "6795", "6540", "9845", 
"9240", "8323", "6616", "6671", "6669", "8657", "7471", "5517", 
"9744", "8408", "5605", "6671", "7154", "9664", "6053", "8368", 
"9664", "7483", "6502", "7772", "7471", "7243", "6143", "7253", 
"6153", "8820", "6951", "6771", "9750", "9161", "9667", "8876", 
"7885", "6155", "9161", "5648", "6404", "9573", "8846", "6359", 
"5997", "9744", "9682", "8708", "8665", "8678", "6947", "8168", 
"6912", "9012", "7345", "7564", "9793", "5483", "8278", "8606", 
"9493", "5635", "7604", "6794", "8945", "6510", "6299", "7192", 
"9741", "9664", "8323", "7222", "5732", "6273", "9202", "8757", 
"7568", "9602", "8763", "8168", "7468", "7109", "8611", "5643", 
"9111", "5925", "7406", "6331", "6093", "7990", "8790", "9468", 
"6243", "9631", "9676", "8945", "7057", "7672", "6429", "9277", 
"9628", "5837", "8551", "9251", "7624", "7143", "9602", "6673", 
"7155", "8248", "6566", "6669", "7047", "9457", "8741", "8739", 
"7483", "6934", "9042", "5885", "7525", "8906", "6442", "8008", 
"6795", "8594", "7604", "8239", "6600", "6883", "9228", "6299", 
"8769", "6634", "5570", "8180", "8368", "8782", "7714", "6986", 
"9135", "8128", "9488", "9202", "8567", "6460", "5468", "6192", 
"8763", "6526", "6011", "7825", "9811", "9065", "5411", "8044", 
"5873", "7785", "6876", "7406", "8790", "6042", "5921", "8783", 
"6025", "7710", "8483", "6837", "7317", "7675", "7214", "9837", 
"6523", "5503", "9815", "8726", "5506", "6422", "9137", "5582", 
"8952", "9827", "6164", "8558", "9202", "9690", "6153", "7790", 
"8368", "9573", "9501", "7707", "7598", "9648", "5614", "8220", 
"6646", "6874", "7869", "9744", "7345", "8787", "5605", "7518", 
"6411", "6560", "6613", "5408", "5968", "8967", "7929", "5604", 
"6340", "6334", "8078", "8939", "7411", "6142", "9845", "9499", 
"7929", "6883", "6114", "7447", "9552", "9555", "8483", "8345", 
"8982", "5925", "6215", "9313", "7518", "6851", "6530", "6422", 
"7915", "8870", "7153", "6530", "9469", "6874", "7555", "9202", 
"9372", "8757", "6560", "9369", "5468", "9717", "9348", "8947", 
"7920", "7718", "7155", "6997", "9667", "9811", "6400", "9012", 
"5849", "8674", "7895", "7406", "8429", "6014", "9037", "7017", 
"7990", "8095", "6938", "5755", "5468", "9802", "8941", "9084", 
"7718", "9573", "7878", "7941", "5732", "9777", "7564", "8667", 
"8975", "7304", "9828", "5548", "6831", "5468", "6442", "9137", 
"6560", "9676", "9111", "9802", "5837", "6025", "8422", "7449", 
"9251", "8323", "7170", "9862", "6131", "6305", "7122", "8611", 
"9558", "6634", "8130", "8967", "6774", "5641", "7879", "6517", 
"8105", "8129", "6771", "6866", "6994", "9085", "9398", "8912", 
"9729", "8772", "5695", "5605", "8551", "6056", "7316", "6333", 
"8326", "6108", "6651", "9027", "7532", "8985", "8412", "9667", 
"6417", "5605", "9747", "5582", "7635", "5842", "8282", "9861", 
"6392", "9746", "8770", "6689", "8134", "9244", "7585", "9623", 
"9364", "5692", "9558", "5794", "7192", "5741", "5610", "9741", 
"8038", "5614", "7772", "6634", "6020", "7397", "8420", "5374", 
"6581", "5874", "5827", "9291", "5751", "8405", "7096", "9102", 
"7565", "7735", "7214", "7171", "8409", "7990", "5753", "9832", 
"9602", "7928", "7496", "8790", "6168", "8178", "7293", "7506", 
"8648", "9777", "7191", "8310", "9450", "9570", "8743", "9454", 
"8461", "7599", "8312", "5728", "7255", "8523", "6186", "7534", 
"8053", "9522", "8982", "8522", "9387", "7208", "6325", "5610", 
"9493", "5837", "6843", "7122", "8870", "7034", "5789", "6798", 
"6525", "9381", "6700", "6146", "8830", "6338", "9793", "7785", 
"8309", "6359", "7214", "8447", "8017", "9772", "9701", "9366", 
"9847", "5905", "6045", "5517", "8416", "8456", "6600", "8280", 
"9221", "5495", "7668", "8329", "6114", "7328", "6311", "7151", 
"8906", "9723", "9135", "9481", "6951", "8967", "6972", "6807", 
"6735", "8310", "5692", "8142", "9493"), date = structure(c(12787, 
12791, 12793, 12795, 12797, 12803, 12807, 12809, 12813, 12814, 
12814, 12816, 12817, 12819, 12820, 12821, 12822, 12822, 12823, 
12824, 12825, 12826, 12827, 12828, 12830, 12832, 12834, 12837, 
12839, 12840, 12842, 12842, 12842, 12842, 12842, 12842, 12842, 
12842, 12845, 12846, 12847, 12847, 12848, 12849, 12849, 12850, 
12850, 12851, 12851, 12852, 12852, 12853, 12854, 12854, 12855, 
12855, 12856, 12856, 12857, 12859, 12861, 12862, 12864, 12865, 
12867, 12868, 12869, 12869, 12870, 12872, 12873, 12873, 12873, 
12873, 12873, 12873, 12873, 12873, 12873, 12873, 12873, 12873, 
12873, 12875, 12876, 12877, 12878, 12878, 12879, 12879, 12880, 
12880, 12880, 12880, 12881, 12882, 12882, 12882, 12883, 12883, 
12884, 12884, 12885, 12885, 12885, 12886, 12886, 12886, 12887, 
12887, 12888, 12889, 12890, 12891, 12892, 12893, 12894, 12895, 
12896, 12897, 12898, 12899, 12900, 12901, 12902, 12903, 12903, 
12903, 12903, 12903, 12903, 12903, 12903, 12903, 12903, 12903, 
12903, 12903, 12903, 12903, 12903, 12903, 12903, 12903, 12905, 
12905, 12906, 12907, 12908, 12908, 12908, 12909, 12909, 12909, 
12909, 12910, 12910, 12910, 12910, 12911, 12911, 12912, 12912, 
12912, 12912, 12913, 12913, 12913, 12914, 12914, 12914, 12915, 
12915, 12915, 12915, 12916, 12916, 12916, 12916, 12917, 12917, 
12917, 12918, 12918, 12919, 12920, 12921, 12921, 12922, 12923, 
12924, 12924, 12925, 12926, 12927, 12927, 12928, 12929, 12929, 
12930, 12931, 12931, 12932, 12934, 12934, 12934, 12934, 12934, 
12934, 12934, 12934, 12934, 12934, 12934, 12934, 12934, 12934, 
12934, 12934, 12934, 12934, 12934, 12934, 12934, 12934, 12934, 
12934, 12934, 12934, 12934, 12934, 12935, 12936, 12936, 12937, 
12938, 12938, 12939, 12939, 12939, 12939, 12939, 12940, 12940, 
12940, 12940, 12941, 12941, 12941, 12941, 12941, 12942, 12942, 
12942, 12942, 12942, 12942, 12943, 12943, 12943, 12943, 12943, 
12944, 12944, 12944, 12944, 12945, 12945, 12945, 12945, 12945, 
12946, 12946, 12946, 12946, 12946, 12946, 12947, 12947, 12947, 
12947, 12947, 12947, 12948, 12948, 12948, 12948, 12949, 12949, 
12950, 12950, 12951, 12951, 12951, 12952, 12952, 12952, 12953, 
12954, 12954, 12955, 12955, 12956, 12956, 12957, 12957, 12958, 
12959, 12959, 12959, 12960, 12961, 12961, 12962, 12963, 12963, 
12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 
12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 
12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 
12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 12964, 
12964, 12964, 12964, 12964, 12965, 12966, 12966, 12967, 12967, 
12967, 12968, 12969, 12969, 12969, 12969, 12969, 12969, 12970, 
12970, 12970, 12970, 12970, 12970, 12970, 12971, 12971, 12971, 
12971, 12971, 12971, 12971, 12972, 12972, 12972, 12972, 12972, 
12972, 12972, 12973, 12973, 12973, 12973, 12973, 12973, 12973, 
12974, 12974, 12974, 12974, 12974, 12975, 12975, 12975, 12975, 
12975, 12975, 12976, 12976, 12976, 12976, 12976, 12976, 12976, 
12976, 12977, 12977, 12977, 12977, 12977, 12977, 12977, 12978, 
12978, 12978, 12978, 12978, 12978, 12979, 12979, 12980, 12980, 
12981, 12981, 12982, 12982, 12982, 12983, 12983, 12984, 12984, 
12984, 12985, 12986, 12986, 12987, 12987, 12988, 12988, 12989, 
12989, 12989, 12990, 12990, 12991, 12991, 12992, 12992, 12993, 
12993, 12994, 12994, 12995, 12995, 12995, 12995, 12995, 12995, 
12995, 12995, 12995, 12995, 12995, 12995, 12995, 12995, 12995, 
12995, 12995, 12995, 12995, 12995, 12995, 12995, 12995, 12995, 
12995, 12995, 12995, 12995, 12995, 12995, 12995, 12995, 12995, 
12995, 12995, 12995, 12995), class = "Date"), amount = c(700, 
11832, 1000, 4276, 200, 200, 49752, 19961, 1000, 13.4, 42.7, 
200, 800, 5224, 5859, 3242, 200, 800, 6242, 1200, 22349, 17477, 
9000, 20567, 1000, 6600, 500, 3100, 300, 1100, 18.7, 102, 2.9, 
3, 39285, 52.1, 34.1, 18.5, 1000, 37305, 8900, 7618, 7597, 9612, 
10700, 200, 1000, 7041, 300, 12200, 5922, 5810, 2901, 4276, 15263, 
5718, 3058, 10737, 500, 16549, 200, 900, 3100, 4300, 7700, 23851, 
700, 400, 600, 13764, 6.1, 21.7, 157.9, 54, 110.9, 70.4, 140.2, 
14500, 39.3, 30.1, 259.3, 154.9, 87.6, 35400, 12300, 5100, 4807, 
3401, 3375, 6934, 11584, 5404, 5298, 6932, 6559, 18500, 7041, 
2400, 12015, 900, 24863, 22349, 6614, 5582, 37346, 18729, 20203, 
6959, 6148, 22800, 800, 800, 6700, 300, 8500, 6700, 45670, 800, 
12100, 9400, 25700, 600, 400, 6700, 9300, 37.6, 152.2, 182.1, 
225.2, 165.7, 187.8, 115.8, 157.6, 96.1, 112.9, 167, 24.7, 161.8, 
243.6, 196.7, 331.1, 28.7, 190.3, 121, 42538, 13500, 32800, 500, 
400, 3191, 10000, 43493, 22054, 6934, 23638, 7600, 3395, 12368, 
6932, 46096, 1300, 6400, 3300, 4939, 10200, 8100, 8905, 12200, 
9700, 300, 22349, 21971, 4507, 25317, 4327, 18729, 3662, 9222, 
16646, 4470, 1600, 20400, 35000, 29414, 1000, 9900, 5900, 1500, 
3700, 15300, 20700, 2600, 13200, 200, 20600, 12200, 5700, 400, 
3200, 6900, 3600, 16100, 4700, 69.9, 48.7, 211.2, 14.6, 56400, 
197.7, 25.8, 181.2, 254.5, 14.6, 29, 14.6, 105.8, 17.4, 52600, 
14.6, 70.4, 14.6, 277.7, 83.4, 25391, 43.5, 306.9, 195.8, 347.8, 
150.4, 121.6, 131.9, 27900, 13300, 1100, 600, 6000, 26365, 3600, 
6280, 169, 5029, 29902.5, 30100, 53100, 8300, 6825, 9612, 22998, 
3395, 4042, 500, 15200, 12300, 3390, 800, 500, 5842, 2400, 3978, 
15876, 33132, 600, 3756, 3008, 28365, 13900, 17362, 2800, 33790, 
43352, 33524, 5400, 6614, 2552, 9100, 37976, 1474, 1500, 32329.5, 
4600, 5355, 22444, 3334, 52500, 4470, 4197, 67124, 700, 2400, 
8900, 990, 4800, 11900, 20800, 19200, 48015, 3700, 13000, 18400, 
30600, 46443, 8356, 53100, 9600, 19100, 2600, 12050, 3000, 23500, 
21440, 22400, 30146, 9900, 2400, 4600, 23700, 198, 39.4, 234.4, 
30, 262, 182.3, 235.6, 123.1, 109, 174.5, 14.6, 192.1, 150.2, 
14.6, 14.6, 24, 296.8, 268.2, 148.2, 202.5, 349.1, 131.9, 327.2, 
74.8, 14.6, 70.8, 2.2, 179.1, 30, 218.9, 101.8, 31.5, 270.1, 
285.5, 184.9, 22851, 279.2, 14.6, 95.3, 14.6, 17600, 500, 2800, 
12000, 15700, 4680, 7400, 463, 9541, 22798, 13841, 997, 7618, 
8827, 38098, 1727, 6300, 2850, 20673, 15308, 6842, 6991, 601, 
3399, 33000, 7936, 44267, 300, 23381, 37435, 3913, 6559, 10800, 
18347, 18500, 3978, 48098, 2800, 29416, 1505, 3596, 23842, 4146, 
2300, 2962, 506, 2140, 21400, 11900, 2700, 3100, 7591, 19594, 
24266, 8740, 6136, 25282, 2552, 310, 37346, 4407, 36700, 1400, 
6226, 500, 1300, 262, 12245, 32928, 599, 8414, 24009, 10562, 
1900, 1200, 9500, 12600, 12800, 3280, 2200, 700, 4909, 10609, 
6600, 31100, 13534, 2600, 2800, 8769, 1600, 21800, 9900, 33733, 
56300, 20800, 59200, 1800, 3600, 19642, 11800, 11200, 4892, 900, 
1100, 1600, 19300, 1700, 14.6, 130.9, 188.7, 29.7, 14.6, 246.1, 
9.8, 155.4, 172.3, 132.4, 14.6, 177.8, 191.8, 150.4, 190.9, 94.5, 
14.6, 14.6, 189.3, 14.6, 60.5, 14.6, 112.6, 285.9, 354.7, 90, 
132.5, 22500, 14.6, 396, 17.3, 91.7, 14.6, 23, 268.7, 31.8, 65.6
)), row.names = c(NA, -500L), class = "data.frame")

0 个答案:

没有答案