Exemplo n.º 1
0
def test_fireball_sampler_fb():
    graph = GraphReader("facebook").get_graph()
    num_nodes = int(0.2 * graph.number_of_nodes())
    sampler = SpikyBallSampler(mode='fireball',
                               number_of_nodes=num_nodes,
                               initial_nodes_ratio=1e-3,
                               sampling_probability=0.1)

    new_graph = sampler.sample(graph)
    assert type(new_graph) == nx.classes.graph.Graph
    assert sampler.number_of_nodes == new_graph.number_of_nodes()
Exemplo n.º 2
0
def test_reader():
    """
    Testing the graph reading on the Facebook dataset.
    """
    reader = GraphReader("facebook")

    graph = reader.get_graph()

    assert nx.number_of_nodes(graph) == 22470
    assert nx.number_of_edges(graph) == 171002
    assert nx.is_connected(graph) == True
Exemplo n.º 3
0
import networkx as nx

from littleballoffur.dataset import GraphReader

from littleballoffur.node_sampling import RandomNodeSampler, DegreeBasedSampler, PageRankBasedSampler

from littleballoffur.exploration_sampling import CommunityStructureExpansionSampler, CirculatedNeighborsRandomWalkSampler
from littleballoffur.exploration_sampling import LoopErasedRandomWalkSampler, BreadthFirstSearchSampler, DepthFirstSearchSampler, SnowBallSampler
from littleballoffur.exploration_sampling import RandomWalkSampler, RandomNodeNeighborSampler, MetropolisHastingsRandomWalkSampler
from littleballoffur.exploration_sampling import ShortestPathSampler, CommonNeighborAwareRandomWalkSampler, NonBackTrackingRandomWalkSampler
from littleballoffur.exploration_sampling import RandomWalkWithRestartSampler, RandomWalkWithJumpSampler, FrontierSampler, ForestFireSampler

from littleballoffur.edge_sampling import RandomEdgeSamplerWithPartialInduction
from littleballoffur.edge_sampling import RandomEdgeSampler, RandomNodeEdgeSampler, HybridNodeEdgeSampler, RandomEdgeSamplerWithInduction

reader = GraphReader("facebook")

graph = reader.get_graph()

#-------------------
# Snow Ball Sampler
#-------------------

sampler = SnowBallSampler()

new_graph = sampler.sample(graph)

#----------------------------
# Depth First Search Sampler
#----------------------------
Exemplo n.º 4
0
"""Example runs with Little Ball of Fur."""

import networkx as nx

from littleballoffur.dataset import GraphReader
from littleballoffur.node_sampling import RandomNodeSampler, DegreeBasedSampler, PageRankBasedSampler
from littleballoffur.exploration_sampling import RandomWalkSampler, RandomNodeNeighborSampler, MetropolisHastingsRandomWalkSampler
from littleballoffur.exploration_sampling import RandomWalkWithRestartSampler, RandomWalkWithJumpSampler, FrontierSampler, ForestFireSampler
from littleballoffur.edge_sampling import RandomEdgeSampler, RandomNodeEdgeSampler, HybridNodeEdgeSampler, RandomEdgeSamplerWithInduction
from littleballoffur.exploration_sampling import CommunityStructureExpansionSampler, CirculatedNeighborsRandomWalkSampler
from littleballoffur.exploration_sampling import ShortestPathSampler, CommonNeighborAwareRandomWalkSampler, NonBackTrackingRandomWalkSampler
from littleballoffur.edge_sampling import RandomEdgeSamplerWithPartialInduction

reader = GraphReader("twitch")

graph = reader.get_graph()

#-------------------------------------------
# Common Neighbor Aware Random Walk Sampler
#-------------------------------------------

sampler = NonBackTrackingRandomWalkSampler()

new_graph = sampler.sample(graph)

print(nx.transitivity(new_graph))

quit()

#-------------------------------------------
# Common Neighbor Aware Random Walk Sampler
Exemplo n.º 5
0
from littleballoffur.dataset import GraphReader

from littleballoffur.node_sampling import RandomNodeSampler, DegreeBasedSampler, PageRankBasedSampler

from littleballoffur.exploration_sampling import CommunityStructureExpansionSampler, CirculatedNeighborsRandomWalkSampler
from littleballoffur.exploration_sampling import LoopErasedRandomWalkSampler, BreadthFirstSearchSampler, DepthFirstSearchSampler, SnowBallSampler
from littleballoffur.exploration_sampling import RandomWalkSampler, RandomNodeNeighborSampler, MetropolisHastingsRandomWalkSampler
from littleballoffur.exploration_sampling import ShortestPathSampler, CommonNeighborAwareRandomWalkSampler, NonBackTrackingRandomWalkSampler
from littleballoffur.exploration_sampling import RandomWalkWithRestartSampler, RandomWalkWithJumpSampler, FrontierSampler, ForestFireSampler

from littleballoffur.edge_sampling import RandomEdgeSamplerWithPartialInduction
from littleballoffur.edge_sampling import RandomEdgeSampler, RandomNodeEdgeSampler, HybridNodeEdgeSampler, RandomEdgeSamplerWithInduction

# reader = GraphReader("facebook")
reader = GraphReader("tinghua_se_all_partial_graph_numeric")
graph = reader.get_graph()
# #画图
# pos = nx.spring_layout(graph)
# #nx.draw_spring(graph, node_size=15, node_color=node_lable, cmap=plt.get_cmap('hsv'), with_labels = True )
# plt.figure(1)
# nx.draw(graph, node_size=20, cmap=plt.get_cmap('hsv'), with_labels = True, font_size = 6, edge_color = 'red')
# plt.savefig("ba.png")           #输出方式1: 将图像存为一个png格式的图片文件
# plt.show()                            #输出方式2: 在窗口中显示这幅图像

#-------------------
# Snow Ball Sampler
#-------------------

sampler = SnowBallSampler()
sampler.__init__(number_of_nodes=1000, k=100, seed=42)