Structural hole spanners detection via maxBlock method. Parameters ---------- G: easygraph.DiGraph k: int top - k structural hole spanners. f_set: dict, optional user vi shares his/her information on network G at a rate fi. default is a random [0,1) int
(G, k, f_set=None, delta=1, eps=0.5, c=1, flag_weight=False)
| 382 | |
| 383 | @not_implemented_for("multigraph") |
| 384 | def maxBlock(G, k, f_set=None, delta=1, eps=0.5, c=1, flag_weight=False): |
| 385 | """Structural hole spanners detection via maxBlock method. |
| 386 | |
| 387 | Parameters |
| 388 | ---------- |
| 389 | G: easygraph.DiGraph |
| 390 | |
| 391 | k: int |
| 392 | top - k structural hole spanners. |
| 393 | |
| 394 | f_set: dict, optional |
| 395 | user vi shares his/her information on network G at a rate fi. |
| 396 | default is a random [0,1) integer for each node |
| 397 | |
| 398 | delta: float, optional (default: 1) |
| 399 | a small value delta > 0. |
| 400 | |
| 401 | eps: float, optional (default: 0.5) |
| 402 | an error ratio eps with 0 < eps < 1. |
| 403 | |
| 404 | c: int, optional (default: 1) |
| 405 | Success probability 1-n^-c of maxBlock. |
| 406 | |
| 407 | flag_weight: bool, optional (default: False) |
| 408 | Denotes whether each edge has attribute 'weight' |
| 409 | |
| 410 | Returns |
| 411 | ------- |
| 412 | S_list : list |
| 413 | The list of each top-k structural hole spanners. |
| 414 | |
| 415 | See Also |
| 416 | ------- |
| 417 | maxBlockFast |
| 418 | |
| 419 | Examples |
| 420 | -------- |
| 421 | # >>> maxBlock(G, 100) |
| 422 | |
| 423 | References |
| 424 | ---------- |
| 425 | .. [1] https://doi.org/10.1016/j.ins.2019.07.072 |
| 426 | |
| 427 | """ |
| 428 | if f_set is None: |
| 429 | f_set = {} |
| 430 | for node in G.nodes: |
| 431 | f_set[node] = random.random() |
| 432 | if not flag_weight: |
| 433 | for edge in G.edges: |
| 434 | G[edge[0]][edge[1]]["weight"] = random.random() |
| 435 | n = G.number_of_nodes() |
| 436 | approximate_opt = _get_estimated_opt(G, f_set, k, c, delta) |
| 437 | print("approximate_opt:", approximate_opt) |
| 438 | L_min = (k + c) * math.log(n, 2) + math.log(4, 2) |
| 439 | L_min = L_min * k * n * n * math.pow(eps, -2) * (8 * k + 2 * eps) |
| 440 | L_min = L_min / approximate_opt |
| 441 | L_min = math.ceil(L_min) |
nothing calls this directly
no test coverage detected