Unexpected field change on edges after triple_apply

User 1824 | 4/28/2015, 3:16:25 PM

Hi,

I was trying calculate some statistic numbers (frequency) for every edge involving a field of edge and another of src vertex. Specifically:

def calc_freq(src, edge, dst):
    edge['freq'] = edge['count']/float(src['n_jobs'])
    return (src, edge, dst)

before applying this function, an example edge looks like:

g.get_edges(src_ids=['JavaScript Developer'], dst_ids=['JSON'])

+----------------------+----------+-------+ | src_id | dst_id | count | +----------------------+----------+-------+ | JavaScript Developer | JSON | 38 | +----------------------+----------+-------+

src vertex looks like: g.get_vertices(['JavaScript Developer']) +----------------------+--------+ | __id | n_jobs | +----------------------+--------+ | JavaScript Developer | 344 | +----------------------+--------+

After applying the calculation function:

g.edges['freq'] = .0
g = g.triple_apply(calc_freq, ['freq'])

the example edge became:

+----------------------+----------+-------+----------------+ | src_id | dst_id | count | freq | +----------------------+----------+-------+----------------+ | JavaScript Developer | JSON | 12 | 0.110465116279 | +----------------------+----------+-------+----------------+

freq calculation went well with correct value however the count field was changed to 12 from 38 originally even though I specified ['freq'] as the only mutated field in triple_apply.

Did I do something wrong with function definition or applying the triple_apply??

Any idea would be appreciated.

(Apologize for the poor format of the output, tried but couldn't fix it)

Yun

Comments

User 91 | 5/4/2015, 5:41:27 PM

This should not happen. Can you send us some code so we can repro this particular issue?