com.actelion.research.chem.descriptor.pharmacophoretree.TreeUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
package com.actelion.research.chem.descriptor.pharmacophoretree;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class TreeUtils {
/*
* insert an element into an sorted array of length N. Only insert if index is smaller than N
*/
private static void binaryInsert(double[] arr, int[][] indexPairs, double val, int[] indexPair) {
int n = arr.length;
int index = Arrays.binarySearch(arr, val);
if(index<0)
index=-index-1;
else
index = index +1;
if(index> getAdjacencyList(int n, List edges) {
Map> adjacencyList = new HashMap>();
for(int i=0;i());
for(int[] edge : edges) {
int n1 = edge[0];
int n2 = edge[1];
adjacencyList.get(n1).add(n2);
adjacencyList.get(n2).add(n1);
}
return adjacencyList;
}
public static Map> getAdjacencyListWithBondOrders(int n, List edges) {
Map> adjacencyList = new HashMap>();
for(int i=0;i());
for(PharmacophoreTree.BiGramInt edge : edges) {
int n1 = edge.edge[0];
int n2 = edge.edge[1];
adjacencyList.get(n1).put(n2,edge.order);
adjacencyList.get(n2).put(n1, edge.order);
}
return adjacencyList;
}
}