Renaming or Setting labels on Nodes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 274
- PR merge metrics
- No merged PRs in 30d
Description
Hi there,
I want to able to assign labels to the GeneralGraph similar to what you do with the GraphUtils instead of using the default X1...Xn notation.
This is what I tried:
cg.G.get_node_names()
['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9']
for i, node in enumerate(cg.G.get_nodes()):
node_name = labels[i] if labels is not None else node.get_name()
node.set_name(node_name)
cg.G.get_node_names()
['IMPRESSIONS',
'CLICKS',
'CONVERSIONS',
'AD_SPEND_USD',
'REVENUE_USD',
'NUM_ORDERS',
'AOV_USD',
'VISITORS',
'SESSIONS']
Which looks good but I think it destroys the internal lookup table, when I want to see the edges it just complains of a keyerror:
Maybe I have to relabel the node_map? Any help will be appreciated.
I know you are working on supporting Pandas DataFrames directly but a short workaround will get me through this problem for the time being.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing GeneralGraph.get_nodes(), node.set_name(), get_node_names(), and the internal node lookup used when retrieving edges. Reproduce the KeyError after renaming nodes and determine how the lookup remains consistent with node labels. Done means custom labels work without breaking edge access or graph queries.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100