I am a newbie in using python and I am in need of some help.
I am trying to built a weighted and undirected k-nearest-neighbors graph for a given 13-dimensional dataset containing 200 data points.
For a start, I created an 3-dimensional embedding via PCA (preserving up to 98% of the initial data structure). I also created the embedding scatter plot using matplotlib and a similarity matrix containing each data point's distance to it's 10 nearest neighbors using sklearn.neighbors.kneighbors_graph. The resulting matrix is not a symmetric one and would lead me to a directed graph.
What I want to do is to create an undirected graph, using the distances as edge weights and each data point as a vertex. Focusing on the "undirected" part of the process, this means that: (A) two vertices (let's say v-i and v-j) would be connected with an undirected edge if v-i is among the k-nearest-neighbors of v-j or if v-j is among the k-nearest-neighbors of v-i. (B) two vertices would be connected with an undirected edge if v-i is and among the k-nearest_neighbors of v-j and v-j is among the k-nearest-neighbors of v-i. The resulting similarity matrix (using either (A) or (B) would be a symmetric one).
Unfortunately, I have no idea how to do this or how to plot it. Does anyone have a clue?
Thanks in advance!!!
I tried using Networkx, but I'm afraid it doesn't work.