Find K-shortest Path in Orientdb - orientdb

I am new to OrientDB and I am trying to find top k shortest path in my graph.So I am creating my algorithm by applying from Yen's algorithm but I do not know how to use it to work in OrientDB ,or is there another ways to find K-shortest path in Orient Graph?
How should I do ?
Thank for all helping :]

If you already have the shortest path (only the shorter) could use directly the function present in OrientDB ShortestPath:

Related

RDKit: generate fingerprints from ZINC database for cluster analysis

I'm new to RDKit. I need to do a cluster analysis of a database of compounds.
I've downloaded 191K compounds from ZINC database in 3D mol2 format and now I need to obtain fingerprints using RDKit.
First, I don't understand if it's possible to convert mol2 format into fingerprints and what kind of fingerprints is better for this type of analysis (I need to understand what chemotypes I have in the database in order to - eventually - find some representatives).
Does anyone have suggestions?(practical suggestions are really appreciated, too).
Thanks
RdKit supports the mol2 file loading. You can use the MolFromMol2File function for that.
from rdkit import Chem
mol2_paths = ['path1', 'path2', 'path3', ......]
mols = []
for path in mol2_paths:
mols.append(Chem.MolFromMol2File(path))
The above function will load all the mol2 files and create a RdKit molecule object for all of them. Once an object is created, you can use it to calculate any of the properties (similar to how you would calculate if you had a SMILES string).
Now, for clustering, RdKit has a ClusterData module, you can use that. See the module here. See an example usage of the module here. Another example here. Check out this presentation on different methods of clustering in RdKit here. An alternative way to cluster here.
Hope this should be a sufficient information for you to go ahead.

How to include car ferries in OSMnx graphs

Is it possible to have OSMnx (great tool BTW) include car ferries when building a graph? Failing that, what would be the most direct way to build such a graph? The problem isn't just that the ferry routes themselves aren't present but, without the ferries, islands that are in reality reachable by car aren't included in the road network.
I have tried using osmnx.settings.useful_tags_way to no avail. Using 'route'='ferry' in overpass-api returns what I would like to include in the graph so I have been editing the OSMnx downloads.py file trying to alter the overpass-api call directly.
Thanks!
First pass (hacky)
I've came up with fairly hacky partial solution by editing osmnx's downloads.py file and replacing the line (originally around line 350):
query_str = f"{overpass_settings};(way{osm_filter}(poly:'{polygon_coord_str}');>;);out;"
with:
osm_filter2 = f'["route"="ferry"]'
query_str = f"{overpass_settings};(way{osm_filter}(poly:'{polygon_coord_str}');>;way{osm_filter2}(poly:'{polygon_coord_str}');>;);out;"
The query string format took some trial and error. If this, or something like it, turns out to be the best approach, I'll try to make it more broadly applicable (add "ferry" to the predefined filter list rather than hardcoded, pass a list of filters, etc).
Much Better
I found that building separate graphs and unioning them using networkx.union or networkx.disjoint_union did not give usable results. So I have added a multiple filter capability to my version of the osmnx downloads.py file. I also added some additional network type options. So it's now possible to pass, for instance, "ferry" as a network_type for the osmnx.graph_from_* functions:
network_type = "ferry"
I can also now pass multiple network types using a pipe delimiter:
network_type = "drive|ferry"
to get a graph that is the union of the two. When doing this, I found that it's useful to create a second ferry-only graph and use that as a reference to update the tags in the combined network graph. It is also better to load non-simplified graphs at first and and simplify it/them yourself after this step.
Still experimenting
Still having some issues with non-connectedness - now in the ferry-only network. Car ferries at isolated crossings than don't share a harbor with a through-ferry are not included in the ferries-only graphs and therefore the tags of their counterparts in the combined network aren't getting updated as needed. The ferries in the combined network (network_type = "drive|ferry") are all present and connected correctly and therefore their respective islands are now on the road network - which is great. But, because their tags aren't being updated, these isolated ferries are getting default highway speeds (and I'm doing travel time analysis). I can use work around this using:
if not 'highway' in edge[3]:
but, for a robust solution, I think we want to be able to tag them explicitly.
I'd still love to hear what other think.

How do I make use of ILocation source and target in custom routing?

This is my sample network and idea of trying how to make a new routing instead of just the shortest path (the path i want to follow is via the pink arrows)
What am I missing here to make my predefined function work?
Fixing the basics
As explained here, you can't instantiate a Java List, because it is an interface. You can however instantiate any implementing Class of a List, for example an ArrayList.
With this in mind your code will look like this:
List<Path> myPath = new ArrayList<Path>();
myPath.add(path14);
myPath.add(path8);
myPath.add(path);
myPath.add(path1);
myPath.add(path4);
myPath.add(path13);
return myPath;
So far for the basics.
Where to go from here
To get it to consider your actual source and destination for the route planning, define both as input parameters of type ILocation in the properties of the function.
Now comes the really tricky part: writing your own or importing a routing algorithm that can give you that list of paths automatically based on criteria that you define. This is however a topic too broad for this question. The basic steps will be:
Create a graph that represents your AnyLogic path network
Solve the graph routing problem with a solving algorithm (eg. Dijkstra Algorithm), using the graph, the startpoint and the endpoint
Convert the solution you get from the solver back again to an ArrayList that you can work with in AnyLogic
You can do these steps on your own, eg. by implementing the Dijkstra Algorithm yourself, or you import into AnyLogic one of the available graph solving Java packages like JUNG or Graphhopper. In this article I explain step by step how to do so with JUNG.

training a new model using pascal kit

need some help on this.
Currently I am doing a project on computer vision that requires me to train a new model to detect a certain object.
In this case, I am using the system provided by P. Felzenszwalb, D. McAllester, D. Ramaman and his team => Discriminatively trained deformable part models which is implemented in Matlab.
Project webpage: http://www.cs.uchicago.edu/~pff/latent/.
However I have no idea how to direct the system to use my dataset(a collection of images and annotation) which is different from the the PASCAL datasets so as to train a new model.
By directing, I meant a line of code that allows me to change the dataset the system reads from, for training a model.
E.g.
% directory for caching models, intermediate data, and results
cachedir = ['/var/tmp/rbg/YOURPATH/' VOCyear '/'];
I tried looking at their Readme and documentation guides but they do not make any mention. Do correct me if I am wrong.
Let me know if I have not made my problem clear enough.
I tried looking at some files such as global.m but no go.
Your help is much appreciated and thanks in advance!
You can try to read pascal.m in the DPM package(voc-release5), there are similar code working on VOC2007/2010 dataset.
There are plenty of parts that need to be adapted to achieve this. For example the voc_config has to be adapted in order to read from your files.
The same with the pascal_train.m function. Depending on the images and the way you parse them, this may require quite some time to adapt this function.
Other functions to consider:
imreadx
pascal_test
pascaleval

How can a Simulink model discover it's own filename and path?

I would like to display some information about a Simulink model, without first knowing the filename. The information will be displayed in the model itself.
Something similar, mfilename, is available for MATLAB programs. Is there an equivalent for Simulink models?
Thanks to Edric I found bdroot, which gives the system name.
Passing this to which makes Matlab find the model using it's search path.
So the solution is model_path = which (bdroot);
One problem is that if you have shadowed files this method may give the incorrect answer.
I think it may be more reliable to get the model parameter in case there is more than one matching model in your path:
model_path = get_param(bdroot, 'FileName');
I think you need gcs http://www.mathworks.com/help/toolbox/simulink/slref/gcs.html