THUDM / GATNE

Source code and dataset for KDD 2019 paper "Representation Learning for Attributed Multiplex Heterogeneous Network"
MIT License
527 stars 141 forks source link

Metapath random walk not considering edge type? #101

Closed Wang-Yu-Qing closed 3 years ago

Wang-Yu-Qing commented 3 years ago

In the walk function:

def walk(args):
    walk_length, start, schema = args
    # Simulate a random walk starting from start node.
    rand = random.Random()

    if schema:
        schema_items = schema.split('-')
        assert schema_items[0] == schema_items[-1]

    walk = [start]
    while len(walk) < walk_length:
        cur = walk[-1]
        candidates = []
        for node in G[cur]:
            if schema == '' or node_type[node] == schema_items[len(walk) % (len(schema_items) - 1)]:
                candidates.append(node)
        if candidates:
            walk.append(rand.choice(candidates))
        else:
            break
    return [str(node) for node in walk]

The walk doesn't consider edge types which is required in the paper's section 4.3 description.

To be specific, given a view r of the network

Wang-Yu-Qing commented 3 years ago

I found that the walk is done upon sub-graph of one specific edge type.

viviqi commented 3 years ago

Actually I have the same opinion with you, schema based random walk sample walks on one specific layer, which means relation type is fixed when sample one random walk sequence.