graph

Longest chain of points satisfying given condition

Longest chain of points satisfying given condition Question: I have a graph of discrete set of points. y x 0 1.000000 1000.000000 1 0.999415 1000.000287 2 0.999420 1000.000358 3 0.999376 1000.000609 4 0.999239 1000.000788 5 0.999011 1000.000967 6 1.000389 1000.001433 7 0.999871 1000.001756 8 0.995070 1000.002723 9 0.996683 1000.003404 I want to determine the longest …

Total answers: 1

How to get an isomorphic graph from another in networkx?

How to get an isomorphic graph from another in networkx? Question: Good morning, everyone. I am currently doing a unit test of a function that processes graphs and it should give similar results in front of isomorphic graphs. So, I would like to output only an isomorphic graph from a networkx graph, but I can’t …

Total answers: 1

Python: Extract all possible mutually exclusive pairs?

Python: Extract all possible mutually exclusive pairs? Question: I have an assignment problem where I have N participants and need to find all possible 2-person assignments where every participant is assigned to exactly one pair. When I use list(combinations(range(100), 2)) I get a "flat" list of about 4000 items, each a pair in the form …

Total answers: 2

Python matplotlib loop not showing anything

Python matplotlib loop not showing anything Question: I’m trying to make a graph that should update periodically using a while loop. This is the code: import matplotlib.pyplot as plt import numpy as np import time fig = plt.figure() while True: data_to_plot = pd.DataFrame(predictions) data_to_plot.columns = [‘A’,’B’,’C’] data_to_plot.plot() plt.pause(10) fig.canvas.draw() fig.canvas.flush_events() What it does is just …

Total answers: 1

Changing the position of coordinate points randomly in a graph using python

Changing the position of coordinate points randomly in a graph using python Question: I have a dataframe of 16 coordinate points. import pandas as pd import matplotlib.pyplot as plt data = {‘x’: [-0.3162277660168379967, -0.3162277660168379967, -0.9486832980505139901, 0.3162277660168379967, 0.9486832980505139901, -0.3162277660168379967, -0.3162277660168379967, -0.9486832980505139901, 0.9486832980505139901, 0.3162277660168379967, 0.3162277660168379967, 0.3162277660168379967, 0.9486832980505139901, -0.9486832980505139901, -0.9486832980505139901, 0.9486832980505139901], ‘y’: [-0.9486832980505139901, 0.3162277660168379967, 0.9486832980505139901, 0.3162277660168379967, -0.3162277660168379967, 0.9486832980505139901, …

Total answers: 1

Change color of candle stick graph in python Plotly

Change color of candle stick graph in python Plotly Question: I have a candle stick graph created to show monthly candles of a stock using plotly in python. I want to customize only one candle for April 2022 (see figure). Here is the complete code. fig = make_subplots(rows=1, cols=1, subplot_titles=[], specs=[[{"secondary_y": True}]], vertical_spacing=0, shared_xaxes=True, row_width=[1.0]) …

Total answers: 1

Python – How to convert a List into an Adjacency List for graphs structure

Python – How to convert a List into an Adjacency List for graphs structure Question: My problem is that I can’t convert a graph constructed through a list into a graph constructed as a dictionary, which must act as an adjacency list. I have already constructed a random generated graph by randomly adding to each …

Total answers: 1

Iterative version of counting connected components

Iterative version of counting connected components Question: I am learning graph theory and am having a hard time counting the number of connected components in a graph. Can someone help me out? I am trying to come up with an iterative version because I am a bit shaky on recursion (still getting the hang of …

Total answers: 1

Strange error: TypeError: forward() takes 2 positional arguments but 3 were given

Strange error: TypeError: forward() takes 2 positional arguments but 3 were given Question: I am trying to train a VAE model. However I keep getting the following error: Traceback (most recent call last): File "/Users/devcharaf/Documents/Uni/UdeM/Internship/newGNN/app/train.py", line 28, in <module> trained_model, loss = train(model, train_data, optimizer, num_epochs=1000, model_type="VAE") File "/Users/devcharaf/Documents/Uni/UdeM/Internship/newGNN/app/utils.py", line 322, in train recon_x, mean, …

Total answers: 2

ImportError: cannot import name 'Sonnet' from 'graphs'

ImportError: cannot import name 'Sonnet' from 'graphs' Question: The code I am trying to run is import graph_nets as gn and the compiler returns ImportError: cannot import name ‘Sonnet’ from ‘graphs’ which traces back to a line in the sonnet package that says from graphs import Sonnet, D3Graph, MatplotGraph (I have seen many similar errors …

Total answers: 1