Skip to content

Commit

Permalink
Migrate Approximate K-Cut estimate to facade
Browse files Browse the repository at this point in the history
  • Loading branch information
vnickolov committed Oct 11, 2023
1 parent 3bdd1f8 commit e2adad6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.neo4j.gds.api.DatabaseId;
import org.neo4j.gds.api.GraphName;
import org.neo4j.gds.api.User;
import org.neo4j.gds.approxmaxkcut.ApproxMaxKCutAlgorithmFactory;
import org.neo4j.gds.approxmaxkcut.config.ApproxMaxKCutBaseConfig;
import org.neo4j.gds.config.AlgoBaseConfig;
import org.neo4j.gds.core.GraphDimensions;
import org.neo4j.gds.core.loading.GraphStoreCatalogService;
Expand Down Expand Up @@ -95,6 +97,16 @@ public <C extends WccBaseConfig> MemoryEstimateResult wcc(Object graphNameOrConf
);
}


public <C extends ApproxMaxKCutBaseConfig> MemoryEstimateResult approxMaxKCut(Object graphNameOrConfiguration, C configuration) {
return estimate(
graphNameOrConfiguration,
configuration,
configuration.relationshipWeightProperty(),
new ApproxMaxKCutAlgorithmFactory<>()
);
}

public <C extends K1ColoringBaseConfig> MemoryEstimateResult k1Coloring(
Object graphNameOrConfiguration,
C configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.neo4j.gds.approxmaxkcut;

import org.neo4j.gds.BaseProc;
import org.neo4j.gds.executor.MemoryEstimationExecutor;
import org.neo4j.gds.procedures.GraphDataScience;
import org.neo4j.gds.procedures.community.approxmaxkcut.ApproxMaxKCutMutateResult;
import org.neo4j.gds.results.MemoryEstimateResult;
Expand Down Expand Up @@ -55,11 +54,7 @@ public Stream<MemoryEstimateResult> estimate(
@Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration,
@Name(value = "algoConfiguration") Map<String, Object> algoConfiguration
) {
return new MemoryEstimationExecutor<>(
new ApproxMaxKCutMutateSpec(),
executionContext(),
transactionContext()
).computeEstimate(graphNameOrConfiguration, algoConfiguration);
return facade.community().approxMaxKCutEstimateMutate(graphNameOrConfiguration, algoConfiguration);
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.neo4j.gds.approxmaxkcut;

import org.neo4j.gds.BaseProc;
import org.neo4j.gds.executor.MemoryEstimationExecutor;
import org.neo4j.gds.procedures.GraphDataScience;
import org.neo4j.gds.procedures.community.approxmaxkcut.ApproxMaxKCutStreamResult;
import org.neo4j.gds.results.MemoryEstimateResult;
Expand Down Expand Up @@ -55,11 +54,7 @@ public Stream<MemoryEstimateResult> estimate(
@Name(value = "graphNameOrConfiguration") Object graphNameOrConfiguration,
@Name(value = "algoConfiguration") Map<String, Object> algoConfiguration
) {
return new MemoryEstimationExecutor<>(
new ApproxMaxKCutStreamSpec(),
executionContext(),
transactionContext()
).computeEstimate(graphNameOrConfiguration, algoConfiguration);
return facade.community().approxMaxKCutEstimateStream(graphNameOrConfiguration, algoConfiguration);
}

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,8 +1315,6 @@ public Stream<MemoryEstimateResult> k1ColoringEstimateWrite(
return Stream.of(estimateBusinessFacade.k1Coloring(graphNameOrConfiguration, config));
}



public Stream<ConductanceStreamResult> conductanceStream(
String graphName,
Map<String, Object> configuration
Expand Down Expand Up @@ -1368,6 +1366,22 @@ public Stream<ApproxMaxKCutMutateResult> approxMaxKCutMutate(
return Stream.of(ApproxMaxKCutComputationResultTransformer.toMutateResult(computationResult));
}

public Stream<MemoryEstimateResult> approxMaxKCutEstimateStream(
Object graphNameOrConfiguration,
Map<String, Object> algoConfiguration
) {
var config = createConfig(algoConfiguration, ApproxMaxKCutStreamConfig::of);
return Stream.of(estimateBusinessFacade.approxMaxKCut(graphNameOrConfiguration, config));
}

public Stream<MemoryEstimateResult> approxMaxKCutEstimateMutate(
Object graphNameOrConfiguration,
Map<String, Object> algoConfiguration
) {
var config = createConfig(algoConfiguration, ApproxMaxKCutMutateConfig::of);
return Stream.of(estimateBusinessFacade.approxMaxKCut(graphNameOrConfiguration, config));
}

public Stream<AlphaSccWriteResult> alphaSccWrite(
String graphName,
Map<String, Object> configuration
Expand Down

0 comments on commit e2adad6

Please sign in to comment.