Search in sources :

Example 1 with BuiltinGraphFactory

use of com.baidu.hugegraph.computer.core.graph.BuiltinGraphFactory in project hugegraph-computer by hugegraph.

the class ComputerContextUtil method initContext.

public static Config initContext(Map<String, String> params) {
    // Set algorithm's parameters
    String algorithmParamsName = params.get(ComputerOptions.ALGORITHM_PARAMS_CLASS.name());
    AlgorithmParams algorithmParams;
    try {
        algorithmParams = (AlgorithmParams) Class.forName(algorithmParamsName).newInstance();
    } catch (Exception e) {
        throw new ComputerException("Can't create algorithmParams, " + "algorithmParamsName = {}", algorithmParamsName);
    }
    algorithmParams.setAlgorithmParameters(params);
    Config config = new DefaultConfig(params);
    GraphFactory graphFactory = new BuiltinGraphFactory();
    Allocator allocator = new DefaultAllocator(config, graphFactory);
    ComputerContext.initContext(config, graphFactory, allocator);
    return config;
}
Also used : BuiltinGraphFactory(com.baidu.hugegraph.computer.core.graph.BuiltinGraphFactory) Allocator(com.baidu.hugegraph.computer.core.allocator.Allocator) DefaultAllocator(com.baidu.hugegraph.computer.core.allocator.DefaultAllocator) GraphFactory(com.baidu.hugegraph.computer.core.graph.GraphFactory) BuiltinGraphFactory(com.baidu.hugegraph.computer.core.graph.BuiltinGraphFactory) AlgorithmParams(com.baidu.hugegraph.computer.algorithm.AlgorithmParams) Config(com.baidu.hugegraph.computer.core.config.Config) DefaultConfig(com.baidu.hugegraph.computer.core.config.DefaultConfig) DefaultConfig(com.baidu.hugegraph.computer.core.config.DefaultConfig) DefaultAllocator(com.baidu.hugegraph.computer.core.allocator.DefaultAllocator) ComputerException(com.baidu.hugegraph.computer.core.common.exception.ComputerException) ComputerException(com.baidu.hugegraph.computer.core.common.exception.ComputerException)

Aggregations

AlgorithmParams (com.baidu.hugegraph.computer.algorithm.AlgorithmParams)1 Allocator (com.baidu.hugegraph.computer.core.allocator.Allocator)1 DefaultAllocator (com.baidu.hugegraph.computer.core.allocator.DefaultAllocator)1 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)1 Config (com.baidu.hugegraph.computer.core.config.Config)1 DefaultConfig (com.baidu.hugegraph.computer.core.config.DefaultConfig)1 BuiltinGraphFactory (com.baidu.hugegraph.computer.core.graph.BuiltinGraphFactory)1 GraphFactory (com.baidu.hugegraph.computer.core.graph.GraphFactory)1