├── .gitignore ├── CMakeLists.txt ├── CMakeSettings.json ├── README.md ├── assemble_bench.py ├── bench.cpp ├── bench_config_gridcut.json ├── bench_config_parallel.json ├── bench_config_serial.json ├── bench_io.cpp ├── bk ├── CHANGES.TXT ├── CMakeLists.txt ├── GPL.TXT ├── README.TXT ├── block.h ├── graph.cpp ├── graph.h ├── instances.inc └── maxflow.cpp ├── demo.cpp ├── graph_io.cpp ├── graph_io.h ├── graph_io.py ├── grid_cut └── CMakeLists.txt ├── hi_pr ├── CMakeLists.txt ├── COPYRIGHT ├── README ├── VERSION ├── construct.cpp ├── hi_pr._main.cpp ├── hi_pr.cpp ├── hi_pr.h ├── hi_pr_main.cpp ├── makefile ├── parser.cpp ├── sample.inp ├── timer.cpp ├── timer.h ├── types.h └── values.h ├── hpf ├── LICENSE.txt └── pseudo.cpp ├── ibfs ├── LICENSE.txt └── ibfs.h ├── json.hpp ├── nbk ├── CHANGES.TXT ├── CMakeLists.txt ├── GPL.TXT ├── README.TXT ├── README.md ├── block.h ├── graph.cpp ├── graph.h ├── instances.inc └── maxflow.cpp ├── prd ├── CMakeLists.txt ├── LICENSE.txt ├── bin │ └── d_maxflow │ │ └── cut_cost ├── code │ ├── assert.h │ ├── d_maxflow │ │ ├── CMakeLists.txt │ │ ├── PRD.cpp │ │ ├── PRD.h │ │ ├── README.txt │ │ ├── array_buckets.h │ │ ├── base_graph.h │ │ ├── cut_cost.cpp │ │ ├── dimacs_parser.cpp │ │ ├── dimacs_parser.h │ │ ├── get_solver.cpp │ │ ├── get_solver.h │ │ ├── hpr1.cpp │ │ ├── hpr1.h │ │ ├── maxflow_BK.cpp │ │ ├── maxflow_BK.h │ │ ├── maxflow_GT.cpp │ │ ├── maxflow_GT.h │ │ ├── maxflow_HPR.cpp │ │ ├── maxflow_HPR.h │ │ ├── maxflow_solver.cpp │ │ ├── maxflow_solver.h │ │ ├── parallel_ARD1.cpp │ │ ├── parallel_ARD1.h │ │ ├── parallel_PRD.cpp │ │ ├── parallel_PRD.h │ │ ├── parallel_discharge.cpp │ │ ├── parallel_discharge.h │ │ ├── region_discharge.cpp │ │ ├── region_discharge.h │ │ ├── region_graph.cpp │ │ ├── region_graph.h │ │ ├── region_splitter.cpp │ │ ├── region_splitter.h │ │ ├── region_splitter2.cpp │ │ ├── region_splitter2.h │ │ ├── save │ │ │ ├── seed_hi_pr.cpp │ │ │ └── seed_hi_pr.h │ │ ├── seed_BK1.cpp │ │ ├── seed_BK1.h │ │ ├── seed_buckets.cpp │ │ ├── seed_buckets.h │ │ ├── seed_hi_pr.cpp │ │ ├── seed_hi_pr.h │ │ ├── seed_hi_pr1.cpp │ │ ├── seed_hi_pr1.h │ │ ├── sequential_discharge.cpp │ │ ├── sequential_discharge.h │ │ ├── solve_dimacs.cpp │ │ ├── solve_random.cpp │ │ ├── stream_ARD1.cpp │ │ ├── stream_ARD1.h │ │ ├── stream_PRD.cpp │ │ └── stream_PRD.h │ ├── data │ │ ├── dataset.cpp │ │ ├── dataset.h │ │ ├── grid_topology.h │ │ └── indexset.h │ ├── debug │ │ ├── except.h │ │ ├── logs.cpp │ │ ├── logs.h │ │ ├── msvcdebug.cpp │ │ ├── msvcdebug.h │ │ ├── performance.cpp │ │ └── performance.h │ ├── defs.h │ ├── dynamic │ │ ├── array_allocator.h │ │ ├── basic_heap.h │ │ ├── block_allocator.cpp │ │ ├── block_allocator.h │ │ ├── buffer.h │ │ ├── dynamic.h │ │ ├── dynamic_array1.h │ │ ├── fixed_array1.h │ │ ├── fixed_array2.h │ │ ├── fixed_vector.h │ │ ├── grow_vector.h │ │ ├── mallocator.h │ │ ├── num_array.cpp │ │ ├── num_array.h │ │ └── static_allocator.h │ ├── exttype │ │ ├── arrayn.h │ │ ├── arrays.h │ │ ├── convolution.h │ │ ├── exttype.h │ │ ├── fixed_vect.h │ │ ├── intn.h │ │ ├── itern.h │ │ ├── ivector.h │ │ ├── key_less.h │ │ ├── minmax.h │ │ ├── pvect.cpp │ │ └── pvect.h │ ├── files │ │ ├── xfs.cpp │ │ └── xfs.h │ ├── geom │ │ ├── Zn.h │ │ ├── geom.h │ │ ├── grid │ │ │ ├── grid.cpp │ │ │ └── grid.h │ │ ├── imatrix.h │ │ ├── math.cpp │ │ ├── math.h │ │ ├── nmmatrix.h │ │ ├── p2geometry │ │ │ ├── hpoly.h │ │ │ ├── p2geometry.cpp │ │ │ └── p2geometry.h │ │ ├── r1geometry │ │ │ ├── r1geometry.cpp │ │ │ └── r1geometry.h │ │ ├── r2geometry │ │ │ ├── convexpoly.h │ │ │ ├── inthpolyrasterizer.cpp │ │ │ ├── inthpolyrasterizer.h │ │ │ ├── r2geometry.cpp │ │ │ ├── r2geometry.h │ │ │ ├── r2grid.cpp │ │ │ ├── r2grid.h │ │ │ ├── vect2.cpp │ │ │ └── vect2.h │ │ ├── r3geometry │ │ │ ├── flatpoly.h │ │ │ ├── r3geometry.cpp │ │ │ ├── r3geometry.h │ │ │ ├── r3grid.cpp │ │ │ ├── r3grid.h │ │ │ ├── vect3.cpp │ │ │ └── vect3.h │ │ ├── transform │ │ │ └── homography │ │ │ │ ├── homography.cpp │ │ │ │ ├── homography.h │ │ │ │ ├── hsolver.cpp │ │ │ │ ├── hsolver.h │ │ │ │ ├── hvect.cpp │ │ │ │ ├── hvect.h │ │ │ │ ├── p3transform.cpp │ │ │ │ └── p3transform.h │ │ ├── vectn.cpp │ │ └── vectn.h │ ├── hi_pr │ │ ├── COPYRIGHT │ │ ├── README │ │ ├── VERSION │ │ ├── construct.cpp │ │ ├── hi_pr._main.cpp │ │ ├── hi_pr.cpp │ │ ├── hi_pr.h │ │ ├── hi_pr_main.cpp │ │ ├── makefile │ │ ├── parser.cpp │ │ ├── sample.inp │ │ ├── timer.cpp │ │ ├── timer.h │ │ ├── types.h │ │ └── values.h │ ├── maxflow-v3.0 │ │ ├── CHANGES.TXT │ │ ├── Doxyfile │ │ ├── README.TXT │ │ ├── block.h │ │ ├── doc │ │ │ └── html │ │ │ │ ├── annotated.html │ │ │ │ ├── block_8h-source.html │ │ │ │ ├── block_8h.html │ │ │ │ ├── class_block-members.html │ │ │ │ ├── class_block.html │ │ │ │ ├── class_d_block-members.html │ │ │ │ ├── class_d_block.html │ │ │ │ ├── class_graph-members.html │ │ │ │ ├── class_graph.html │ │ │ │ ├── class_graph_1_1graph__save-members.html │ │ │ │ ├── class_graph_1_1graph__save.html │ │ │ │ ├── dir_205676351b297158e55e7d2e34ca0fa6.html │ │ │ │ ├── dir_275089585c7fc1b5fd5d7d42c69cb1da.html │ │ │ │ ├── dir_3daa9d609eb87f0461c37bfefb82668a.html │ │ │ │ ├── dir_59a0b0afaee80e6b6ba28d0c994cce44.html │ │ │ │ ├── dir_b4dbe4a135452c8ff688d9678925d1ed.html │ │ │ │ ├── dir_b5f02c12a37c9034511e423cb4d2b66a.html │ │ │ │ ├── dir_cb63ed9d9a81cde8c4b316529319d0c6.html │ │ │ │ ├── dir_e370e6d1a20533cb983b5c8cb75d2fe2.html │ │ │ │ ├── dirs.html │ │ │ │ ├── doxygen.css │ │ │ │ ├── doxygen.png │ │ │ │ ├── files.html │ │ │ │ ├── functions.html │ │ │ │ ├── functions_enum.html │ │ │ │ ├── functions_eval.html │ │ │ │ ├── functions_func.html │ │ │ │ ├── functions_type.html │ │ │ │ ├── functions_vars.html │ │ │ │ ├── globals.html │ │ │ │ ├── globals_defs.html │ │ │ │ ├── graph_8cpp-source.html │ │ │ │ ├── graph_8cpp.html │ │ │ │ ├── graph_8h-source.html │ │ │ │ ├── graph_8h.html │ │ │ │ ├── index.html │ │ │ │ ├── instances_8inc-source.html │ │ │ │ ├── instances_8inc.html │ │ │ │ ├── maxflow_8cpp-source.html │ │ │ │ ├── maxflow_8cpp.html │ │ │ │ ├── struct_block_1_1block__st-members.html │ │ │ │ ├── struct_block_1_1block__st.html │ │ │ │ ├── struct_d_block_1_1block__st-members.html │ │ │ │ ├── struct_d_block_1_1block__st.html │ │ │ │ ├── struct_graph_1_1arc-members.html │ │ │ │ ├── struct_graph_1_1arc.html │ │ │ │ ├── struct_graph_1_1graph__save_1_1arc__saved-members.html │ │ │ │ ├── struct_graph_1_1graph__save_1_1arc__saved.html │ │ │ │ ├── struct_graph_1_1graph__save_1_1node__saved-members.html │ │ │ │ ├── struct_graph_1_1graph__save_1_1node__saved.html │ │ │ │ ├── struct_graph_1_1node-members.html │ │ │ │ ├── struct_graph_1_1node.html │ │ │ │ ├── struct_graph_1_1nodeptr-members.html │ │ │ │ ├── struct_graph_1_1nodeptr.html │ │ │ │ ├── tab_b.gif │ │ │ │ ├── tab_l.gif │ │ │ │ ├── tab_r.gif │ │ │ │ ├── tabs.css │ │ │ │ ├── union_d_block_1_1block__item__st-members.html │ │ │ │ └── union_d_block_1_1block__item__st.html │ │ ├── graph.cpp │ │ ├── graph.h │ │ ├── instances.inc │ │ └── maxflow.cpp │ ├── maxflow │ │ ├── CHANGES.TXT │ │ ├── DOWNLOAD.txt │ │ ├── README.TXT │ │ ├── block.h │ │ ├── graph.cpp │ │ ├── graph.h │ │ ├── instances.inc │ │ └── maxflow.cpp │ ├── mtmaxflow │ │ ├── README.txt │ │ ├── demo │ │ │ ├── fig8.m │ │ │ └── segmentation.m │ │ ├── graph_tools │ │ │ ├── README.txt │ │ │ ├── cut_delta.m │ │ │ ├── draw_graph.m │ │ │ ├── draw_graph3D.m │ │ │ ├── edges3D.m │ │ │ ├── edges4connected.m │ │ │ ├── edges8connected.m │ │ │ ├── plot_contour.m │ │ │ ├── test_2D.m │ │ │ └── test_3D.m │ │ ├── images │ │ │ └── waterfall.bmp │ │ ├── make.m │ │ ├── maxflow_dd.cpp │ │ ├── maxflow_dd.h │ │ ├── mtmaxflow.vcproj │ │ ├── split-cpp │ │ │ ├── cppmatrix.h │ │ │ ├── maxflowmulti.cpp │ │ │ ├── maxflowmultiint.cpp │ │ │ ├── maxflowsingle.cpp │ │ │ ├── maxflowsingleint.cpp │ │ │ ├── mextiming.h │ │ │ ├── mexutils.h │ │ │ ├── parallelmaxflow.cpp │ │ │ └── parallelmaxflow.h │ │ └── startup.m │ └── streams │ │ ├── advstreaming.cpp │ │ ├── advstreaming.h │ │ ├── binary_stream.cpp │ │ ├── binary_stream.h │ │ ├── file_stream.cpp │ │ ├── file_stream.h │ │ ├── text_stream.cpp │ │ ├── text_stream.h │ │ ├── virtual_stream.cpp │ │ ├── virtual_stream.h │ │ ├── xstringstream.cpp │ │ └── xstringstream.h ├── matlab │ ├── d_maxflow │ │ ├── clear_cache.m │ │ ├── collect_parallel.m │ │ ├── collect_reports.m │ │ ├── collect_streaming.m │ │ ├── data.m │ │ ├── get_reports.m │ │ ├── parallel_competition.m │ │ ├── plot_sweeps_vs_regions.m │ │ ├── plot_time_cpus.m │ │ ├── print_i.m │ │ ├── print_size.m │ │ ├── print_size2.m │ │ ├── print_time.m │ │ ├── read_report.m │ │ ├── rnd_plots.m │ │ ├── rrename.m │ │ ├── sim_eci.m │ │ ├── solve_all.m │ │ ├── sweeps_vs_regions.m │ │ └── test.m │ └── mtools │ │ ├── argmax.m │ │ ├── cc.m │ │ ├── col.m │ │ ├── conv2_gauss.m │ │ ├── cross2.m │ │ ├── deprecated │ │ └── inv_mon.m │ │ ├── dirr.m │ │ ├── eci.m │ │ ├── file_ext.m │ │ ├── file_name.m │ │ ├── file_path.m │ │ ├── fixpath.m │ │ ├── force_path.m │ │ ├── full_path.m │ │ ├── gauss_f1.m │ │ ├── get_cell_field.m │ │ ├── img │ │ ├── bbox.m │ │ ├── cfigure.m │ │ ├── clip_bd.m │ │ ├── color_nans.m │ │ ├── colormap_sq_metric.m │ │ ├── conv1_gauss.m │ │ ├── conv2_gauss.m │ │ ├── conv2_sep.m │ │ ├── conv2same.m │ │ ├── conv3_gauss.m │ │ ├── cumwin.m │ │ ├── density_gmmd1_ml.m │ │ ├── density_gmmd2_ml.m │ │ ├── fbox.m │ │ ├── ffit.m │ │ ├── gauss_filter_d.m │ │ ├── gray2rgb.m │ │ ├── hist2i.m │ │ ├── histi.m │ │ ├── im2gray.m │ │ ├── im2rgb.m │ │ ├── im2v.m │ │ ├── imagesc_g.m │ │ ├── imagesc_j.m │ │ ├── imcapture.m │ │ ├── imcrop.m │ │ ├── jetim.m │ │ ├── meanwin.m │ │ ├── mgriddata.m │ │ ├── mimagesc.m │ │ ├── minterp2.m │ │ ├── minverse.m │ │ ├── mmeshgrid.m │ │ ├── mmontage.m │ │ ├── mrgb2ind.m │ │ ├── pad_bd.m │ │ ├── pad_bd_copy.m │ │ ├── pdffig.m │ │ ├── prect.m │ │ ├── prescale.m │ │ ├── printfig.m │ │ ├── show_im_bd.m │ │ ├── show_mask.m │ │ ├── template_matching.m │ │ └── v2im.m │ │ ├── invcum.m │ │ ├── kron3.m │ │ ├── lin_size.m │ │ ├── logsumexp.m │ │ ├── lstrtrim.m │ │ ├── maccumarray.m │ │ ├── madd.m │ │ ├── maddpath.m │ │ ├── meanci.m │ │ ├── medit.m │ │ ├── mind.m │ │ ├── mmax.m │ │ ├── mmean.m │ │ ├── mmin.m │ │ ├── mminus.m │ │ ├── mpath.m │ │ ├── mrange.m │ │ ├── mselect.m │ │ ├── msize.m │ │ ├── msparse.m │ │ ├── msub.m │ │ ├── msub2ind.m │ │ ├── msum.m │ │ ├── msystem.m │ │ ├── multi_ind2sub.m │ │ ├── multi_rep.m │ │ ├── multi_sub2ind.m │ │ ├── mxlim.m │ │ ├── my_path.m │ │ ├── num2print.m │ │ ├── path_reduce.m │ │ ├── platform_shared_lib_ext.m │ │ ├── platform_static_lib_ext.m │ │ ├── predci.m │ │ ├── rel_name.m │ │ ├── row.m │ │ ├── rstrtrim.m │ │ ├── select.m │ │ ├── swap.m │ │ ├── sys_slashes.m │ │ ├── transp.m │ │ ├── trim_ext.m │ │ ├── unix_slashes.m │ │ ├── win_slashes.m │ │ └── write.m └── projects │ ├── cflags │ ├── d_maxflow │ ├── Backup │ │ └── d_maxflow.sln │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.txt │ ├── UpgradeLog.htm │ ├── cfg.h.in │ ├── cut_cost.cbp │ ├── cut_cost.vcproj │ ├── cut_cost.vcxproj │ ├── cut_cost.vcxproj.user │ ├── d_maxflow.cbp │ ├── d_maxflow.cdb.workspace │ ├── d_maxflow.makefile │ ├── d_maxflow.sln │ ├── d_maxflow.suo │ ├── d_maxflow.vcproj │ ├── d_maxflow.vcxproj │ ├── d_maxflow.vcxproj.user │ ├── d_maxflow_ar.bat │ ├── d_maxflow_dirs.txt │ ├── d_maxflow_dirs_exclude.txt │ ├── doc │ │ └── tests │ │ │ └── parallel_CPU8_64b.png │ ├── index.html │ ├── maxflow_BK.cbp │ ├── maxflow_BK.makefile │ ├── maxflow_BK.vcproj │ ├── maxflow_BK.vcxproj │ ├── maxflow_BK.vcxproj.user │ ├── maxflow_DD.cbp │ ├── maxflow_DD.makefile │ ├── maxflow_DD.vcproj │ ├── maxflow_DD.vcxproj │ ├── maxflow_DD.vcxproj.user │ ├── maxflow_GT.cbp │ ├── maxflow_GT.makefile │ ├── maxflow_GT.vcproj │ ├── maxflow_GT.vcxproj │ ├── maxflow_GT.vcxproj.user │ ├── solve_dimacs.cbp │ ├── solve_dimacs.makefile │ ├── solve_dimacs.vcproj │ ├── solve_dimacs.vcxproj │ ├── solve_dimacs.vcxproj.user │ ├── solve_random.cbp │ ├── solve_random.makefile │ ├── solve_random.vcproj │ ├── solve_random.vcxproj │ └── solve_random.vcxproj.user │ ├── exttype │ ├── exttype.cbp │ ├── exttype.vcproj │ ├── exttype.vcxproj │ ├── exttype.vcxproj.filters │ ├── exttype.vcxproj.user │ ├── makefile │ └── mexopts1.sh │ └── lflags ├── reimpls ├── CMakeLists.txt ├── LICENSE.txt ├── eibfs_i.h ├── eibfs_i_nr.h ├── hpf.h ├── liusun.h ├── mbk.h ├── mbk_r.h ├── parallel_ibfs.h ├── parallel_pr.h ├── robin_hood.h ├── strandmarkkahl.h └── util.h ├── sk ├── CMakeLists.txt ├── parallelmaxflow.cpp └── parallelmaxflow.h ├── snappy ├── .appveyor.yml ├── .gitignore ├── .travis.yml ├── AUTHORS ├── CMakeLists.txt ├── CONTRIBUTING.md ├── COPYING ├── NEWS ├── README.md ├── cmake │ ├── SnappyConfig.cmake.in │ └── config.h.in ├── docs │ └── README.md ├── format_description.txt ├── framing_format.txt ├── snappy-c.cc ├── snappy-c.h ├── snappy-internal.h ├── snappy-sinksource.cc ├── snappy-sinksource.h ├── snappy-stubs-internal.cc ├── snappy-stubs-internal.h ├── snappy-stubs-public.h.in ├── snappy-test.cc ├── snappy-test.h ├── snappy.cc ├── snappy.h ├── snappy_compress_fuzzer.cc ├── snappy_uncompress_fuzzer.cc └── snappy_unittest.cc └── sppr ├── CMakeLists.txt ├── IO.h ├── gettime.h ├── graph.h ├── graphIO.h ├── maxFlow.cpp ├── maxFlow.h ├── maxFlowTime.cpp ├── parallel.h ├── parseCommandLine.h ├── sequence.h └── utils.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # Some Visual Studio directories 35 | out/ 36 | .vs/ 37 | .vscode/ 38 | 39 | # Data files 40 | *.max 41 | *.bbk 42 | 43 | # d_maxflow binary directory 44 | prd/bin 45 | 46 | # Source files in GridCut directory as their license disallows redistribution 47 | grid_cut/*.h 48 | 49 | # Python stuff 50 | __pycache__ 51 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ "msvc_x64_x64" ], 8 | "buildRoot": "${projectDir}\\out\\build\\${name}", 9 | "installRoot": "${projectDir}\\out\\install\\${name}", 10 | "cmakeCommandArgs": "", 11 | "buildCommandArgs": "-v", 12 | "ctestCommandArgs": "", 13 | "variables": [] 14 | }, 15 | { 16 | "name": "x64-Release", 17 | "generator": "Ninja", 18 | "configurationType": "RelWithDebInfo", 19 | "buildRoot": "${projectDir}\\out\\build\\${name}", 20 | "installRoot": "${projectDir}\\out\\install\\${name}", 21 | "cmakeCommandArgs": "", 22 | "buildCommandArgs": "-v", 23 | "ctestCommandArgs": "", 24 | "inheritEnvironments": [ "msvc_x64_x64" ], 25 | "variables": [] 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /assemble_bench.py: -------------------------------------------------------------------------------- 1 | import json 2 | import os 3 | import sys 4 | from glob import glob 5 | import argparse 6 | 7 | 8 | def name_to_entry(f): 9 | return { 10 | 'file_name': f, 11 | 'file_type': f.split('.')[-1], 12 | 'nbor_cap_type': 'int32', 13 | 'term_cap_type': 'int32' 14 | } 15 | 16 | 17 | def is_benchfile(f): 18 | return f.endswith('.bq') or f.endswith('.bbk') 19 | 20 | 21 | def main(argv): 22 | parser = argparse.ArgumentParser( 23 | description="Build 'data_sets' entry for benchmark file" 24 | ) 25 | parser.add_argument('file_glob', default='*', nargs='?', 26 | help='pattern forwarded to glob (default: %(default)s)') 27 | parser.add_argument('--base_file', help='file with JSON data to insert into') 28 | args = parser.parse_args(argv) 29 | 30 | files = sorted(glob(args.file_glob)) 31 | entries = [name_to_entry(os.path.abspath(f)) for f in files if is_benchfile(f)] 32 | 33 | if args.base_file is not None: 34 | with open(args.base_file) as in_file: 35 | bench_data = json.load(in_file) 36 | bench_data['data_sets'] = entries 37 | print(json.dumps(bench_data, indent=2)) 38 | else: 39 | print(json.dumps(entries, indent=2)) 40 | 41 | 42 | if __name__ == '__main__': 43 | main(sys.argv[1:]) 44 | 45 | -------------------------------------------------------------------------------- /bench_config_gridcut.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "GridCut example", 3 | "num_run": 3, 4 | "types": [ 5 | { 6 | "cap": "int32", 7 | "term": "int32", 8 | "flow": "int64", 9 | "index": "int32" 10 | } 11 | ], 12 | "algorithms": [ 13 | "gridcut_mt", 14 | "gridcut" 15 | ], 16 | "parallel": { 17 | "threads": [ 18 | 1, 19 | 2, 20 | 4 21 | ] 22 | }, 23 | "data_sets": [ 24 | { 25 | "file_name": "data/bone.n6c10.max.bbk", 26 | "file_type": "bbk", 27 | "nbor_cap_type": "int32", 28 | "term_cap_type": "int32", 29 | "grid_info": { 30 | "grid_type": "3D_6C", 31 | "width": 256, 32 | "height": 256, 33 | "depth": 119 34 | } 35 | }, 36 | { 37 | "file_name": "data/liver.n6c10.max.bbk", 38 | "file_type": "bbk", 39 | "nbor_cap_type": "int32", 40 | "term_cap_type": "int32", 41 | "grid_info": { 42 | "grid_type": "3D_6C", 43 | "width": 170, 44 | "height": 170, 45 | "depth": 144 46 | } 47 | } 48 | ] 49 | } -------------------------------------------------------------------------------- /bench_config_parallel.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parallel example", 3 | "num_run": 3, 4 | "types": [ 5 | { 6 | "cap": "int32", 7 | "term": "int32", 8 | "flow": "int64", 9 | "index": "int32" 10 | } 11 | ], 12 | "algorithms": [ 13 | "mbk", 14 | "liusun" 15 | ], 16 | "parallel": { 17 | "threads": [ 18 | 1, 2, 4, 8 19 | ] 20 | }, 21 | "data_sets": [ 22 | { 23 | "file_name": "data/bone.n6c10.max.bbk", 24 | "file_type": "bbk", 25 | "nbor_cap_type": "int32", 26 | "term_cap_type": "int32" 27 | }, 28 | { 29 | "file_name": "data/liver.n6c10.max.bbk", 30 | "file_type": "bbk", 31 | "nbor_cap_type": "int32", 32 | "term_cap_type": "int32" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /bench_config_serial.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "serial example", 3 | "num_run": 10, 4 | "types": [ 5 | { 6 | "cap": "int32", 7 | "term": "int32", 8 | "flow": "int64", 9 | "index": "int32" 10 | } 11 | ], 12 | "algorithms": [ 13 | "mbk", 14 | "hpf", 15 | "eibfs_i" 16 | ], 17 | "data_sets": [ 18 | { 19 | "file_name": "data/104_0412_16bins.max.bbk", 20 | "file_type": "bbk", 21 | "nbor_cap_type": "int32", 22 | "term_cap_type": "int32" 23 | }, 24 | { 25 | "file_name": "data/KZ2-tsukuba0.max", 26 | "file_type": "dimacs", 27 | "nbor_cap_type": "int32", 28 | "term_cap_type": "int32" 29 | }, 30 | { 31 | "file_name": "data/bone.n6c10.max.bbk", 32 | "file_type": "bbk", 33 | "nbor_cap_type": "int32", 34 | "term_cap_type": "int32" 35 | }, 36 | { 37 | "file_name": "data/liver.n6c10.max.bbk", 38 | "file_type": "bbk", 39 | "nbor_cap_type": "int32", 40 | "term_cap_type": "int32" 41 | } 42 | ] 43 | } 44 | -------------------------------------------------------------------------------- /bk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | add_library(bk INTERFACE) 4 | target_include_directories(bk INTERFACE .) 5 | -------------------------------------------------------------------------------- /bk/instances.inc: -------------------------------------------------------------------------------- 1 | #include "graph.h" 2 | 3 | #ifdef _MSC_VER 4 | #pragma warning(disable: 4661) 5 | #endif 6 | 7 | // Instantiations: 8 | // IMPORTANT: 9 | // flowtype should be 'larger' than tcaptype 10 | // tcaptype should be 'larger' than captype 11 | 12 | /*template class Graph; 13 | template class Graph; 14 | template class Graph; 15 | template class Graph;*/ 16 | 17 | -------------------------------------------------------------------------------- /grid_cut/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | add_library(grid_cut INTERFACE) 4 | target_include_directories(grid_cut INTERFACE .) -------------------------------------------------------------------------------- /hi_pr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | add_library(hi_pr STATIC hi_pr.cpp construct.cpp timer.cpp parser.cpp) 4 | target_include_directories(hi_pr PUBLIC .) -------------------------------------------------------------------------------- /hi_pr/COPYRIGHT: -------------------------------------------------------------------------------- 1 | COPYRIGHT C 1995 -- 2004 by IG Systems, Inc. 2 | Commercial use requires a license 3 | 4 | This software comes with NO WARRANTY, expressed or implied. By way 5 | of example, but not limitation, we make no representations of warranties 6 | of merchantability or fitness for any particular purpose or that the use 7 | of the software components or documentation will not infringe any patents, 8 | copyrights, trademarks, or other rights. 9 | -------------------------------------------------------------------------------- /hi_pr/README: -------------------------------------------------------------------------------- 1 | HI_PR is an efficient implementation of the push-relabel method. 2 | See 3 | Goldberg and Tarjan, "A New Approach to the Maximum Flow Problem," 4 | J. ACM Vol. 35, 921--940, 1988 5 | and 6 | Cherkassky and Goldberg, "On Implementing Push-Relabel Method for the 7 | Maximum Flow Problem," Proc. IPCO-4, 157--171, 1995. 8 | 9 | The program is designed to run under UNIX/LINUX. 10 | The program reads from the standard input and writes to the standard 11 | output. Run "make" to compile the program. Program name is "hi_pr". 12 | 13 | If the total capacity of arcs out of the source is greater than MAXLONG, 14 | then the flow computed by hi_pr is upper-bounded by MAXLONG and if the 15 | maximum flow value is greater than MAXLONG, then the computed flow is not 16 | maximum. In this case a warning message is printed. To deal with this overflow 17 | problem, edit "types.h" and redefine "excessType" to be "long long int" if 18 | your compiler supports this type of "double" otherwise. 19 | 20 | See makefile for compile-time options. 21 | 22 | The program is available on "as is" basis. It is not guaranteed to 23 | be free of bugs, and IG Systems assumes no responsibility for any 24 | potential problems. 25 | 26 | This software comes with NO WARRANTY, expressed or implied. By way 27 | of example, but not limitation, we make no representations of warranties 28 | of merchantability or fitness for any particular purpose or that the use 29 | of the software components or documentation will not infringe any patents, 30 | copyrights, trademarks, or other rights. 31 | -------------------------------------------------------------------------------- /hi_pr/VERSION: -------------------------------------------------------------------------------- 1 | hi_pr version 3.6, 9/9/06 2 | 3 | hi_pr is a derivative of the h_prf code of Cherkassky and Goldberg. 4 | The code has been rewritten to make it more maintainable and stable. 5 | 6 | Algorithmic changes include array representation of adjacency lists (compared 7 | to the linked list representation in h_prf) and initialization (done by 8 | saturating all out-of-source arcs rather then placing a large excess at 9 | the source); also by default, global update is not performed immediately 10 | after initialization. Old initialization is supported via a compiler option. 11 | 12 | Version 3.2 differs from 3.1 by a slightly different strategy for measuring 13 | work to decide when to envoke the next global update. Version 3.3 fixes a 14 | bug in the second (flow computation) stage, implements excessType better, 15 | and adds a CHECK_SOLUTION compiler option.Version 3.4 adds cType 16 | (capacity type) and the ability to reinitialize computation using init() 17 | function. Version 3.5 adds wave-type initialization, which is better on 18 | some problem families (and worse on others). Version 3.5 also uses less memory. 19 | Version 3.6 adds CYGWIN compatibility. 20 | -------------------------------------------------------------------------------- /hi_pr/hi_pr._main.cpp: -------------------------------------------------------------------------------- 1 | #include "hi_pr.h" 2 | int main(int argc, char *argv[]){ 3 | return hi_pr::main(argc,*argv[]); 4 | }; -------------------------------------------------------------------------------- /hi_pr/hi_pr_main.cpp: -------------------------------------------------------------------------------- 1 | #include "hi_pr.h" 2 | int main(int argc, char *argv[]){ 3 | hi_pr h; 4 | return h.main(argc,argv); 5 | }; -------------------------------------------------------------------------------- /hi_pr/makefile: -------------------------------------------------------------------------------- 1 | # makefile for programs and generator 2 | 3 | # compiler flags: 4 | # 5 | # CHECK_SOLUTION check if at the end the sink is unreachable 6 | # from the source 7 | # CUT_ONLY define to compute min-cut but not max-flow 8 | # PRINT_STAT define to print detailed operation statistics 9 | # PRINT_FLOW define to print out flow value 10 | # PRINT_CUT define to print out the sink size of the cut 11 | # WAVE_INIT wave-style initialization (initial global update, 12 | # then a wave of flow pushing). Better on some problems 13 | # OLD_INIT define to use old-style initialization (large excess 14 | # at the source, global update) 15 | # INIT_UPDATE perform initial global update 16 | # EXCESS_TYPE_LONG set excessType to long, otherwise it is long long int 17 | # if "long long int" not supported, change to "double" 18 | # (in types.h) 19 | 20 | CCOMP = g++ 21 | CFLAGS = -O4 -DNDEBUG -DPRINT_STAT -DCHECK_SOLUTION -Wall 22 | #CFLAGS = -g -DPRINT_FLOW -DEXCESS_TYPE_LONG -DPRINT_STAT -DCHECK_SOLUTION -Wall 23 | 24 | all: hi_pr.exe hi_prw.exe hi_pro.exe 25 | hi_pr.exe: hi_pr.cpp parser.o types.h timer.o 26 | $(CCOMP) $(CFLAGS) -o hi_pr hi_pr.cpp construct.cpp hi_pr_main.cpp parser.o timer.o 27 | %.o: %.cpp 28 | $(CCOMP) $(CFLAGS) -c $@ 29 | hi_prw.exe: hi_pr.cpp parser.cpp types.h timer.cpp 30 | $(CCOMP) $(CFLAGS) -DWAVE_INIT -o hi_prw hi_pr.cpp 31 | hi_pro.exe: hi_pr.cpp parser.cpp types.h timer.cpp 32 | $(CCOMP) $(CFLAGS) -DOLD_INIT -o hi_pro hi_pr.cpp 33 | clean: 34 | rm -f hi_pr.exe hi_pro.exe hi_prw.exe *~ 35 | -------------------------------------------------------------------------------- /hi_pr/sample.inp: -------------------------------------------------------------------------------- 1 | p max 8 11 2 | n 1 s 3 | n 8 t 4 | a 1 2 5 5 | a 2 3 5 6 | a 3 4 5 7 | a 4 2 5 8 | a 3 5 2 9 | a 4 7 2 10 | a 5 6 5 11 | a 6 7 5 12 | a 7 5 5 13 | a 7 8 1 14 | a 6 8 4 15 | -------------------------------------------------------------------------------- /hi_pr/timer.cpp: -------------------------------------------------------------------------------- 1 | #include "timer.h" 2 | 3 | #ifndef WIN32 4 | #include 5 | //#include 6 | 7 | float timer () 8 | { 9 | clock_t tt = clock(); 10 | return (float)(double(tt)/CLOCKS_PER_SEC); 11 | } 12 | 13 | #else 14 | 15 | float timer (){ 16 | return 0; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /hi_pr/timer.h: -------------------------------------------------------------------------------- 1 | float timer(); -------------------------------------------------------------------------------- /hi_pr/types.h: -------------------------------------------------------------------------------- 1 | #ifndef hi_pr_types_h 2 | #define hi_pr_types_h 3 | /* defs.h */ 4 | 5 | #ifdef EXCESS_TYPE_LONG 6 | typedef unsigned long excessType; 7 | #else 8 | typedef long long int excessType; /* change to double if not supported */ 9 | #endif 10 | 11 | typedef unsigned long cType; 12 | 13 | typedef /* arc */ 14 | struct arcSt 15 | { 16 | cType resCap; /* residual capasity */ 17 | struct nodeSt *head; /* arc head */ 18 | struct arcSt *rev; /* reverse arc */ 19 | } 20 | arc; 21 | 22 | typedef /* node */ 23 | struct nodeSt 24 | { 25 | arc *first; /* first outgoing arc */ 26 | arc *current; /* current outgoing arc */ 27 | excessType excess; /* excess at the node 28 | change to double if needed */ 29 | long d; /* distance label */ 30 | struct nodeSt *bNext; /* next node in bucket */ 31 | struct nodeSt *bPrev; /* previous node in bucket */ 32 | } node; 33 | 34 | 35 | typedef /* bucket */ 36 | struct bucketSt 37 | { 38 | node *firstActive; /* first node with positive excess */ 39 | node *firstInactive; /* first node with zero excess */ 40 | } bucket; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /hi_pr/values.h: -------------------------------------------------------------------------------- 1 | #define MAXLONG 1073741824 2 | -------------------------------------------------------------------------------- /hpf/LICENSE.txt: -------------------------------------------------------------------------------- 1 | LICENSE 2 | 3 | The source code is subject to the following academic license. 4 | Note this is not an open source license. 5 | 6 | Copyright © 2001. The Regents of the University of California (Regents). 7 | All Rights Reserved. 8 | 9 | Permission to use, copy, modify, and distribute this software and its 10 | documentation for educational, research, and not-for-profit purposes, 11 | without fee and without a signed licensing agreement, is hereby granted, 12 | provided that the above copyright notice, this paragraph and the following 13 | two paragraphs appear in all copies, modifications, and distributions. 14 | Contact The Office of Technology Licensing, UC Berkeley, 2150 Shattuck 15 | Avenue, Suite 510, Berkeley, CA 94720-1620, (510) 643-7201, for commercial 16 | licensing opportunities. Created by Bala Chandran and Dorit S. Hochbaum, 17 | Department of Industrial Engineering and Operations Research, 18 | University of California, Berkeley. 19 | 20 | IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, 21 | SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, 22 | ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 23 | REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | 25 | REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED 26 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 | PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED 28 | HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE 29 | MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 30 | -------------------------------------------------------------------------------- /ibfs/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software can be used for research purposes only. 2 | If you use this software for research purposes, you should cite the aforementioned papers 3 | in any resulting publication and appropriately credit it. 4 | 5 | If you require another license, please contact the above. -------------------------------------------------------------------------------- /nbk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | 3 | add_library(bk INTERFACE) 4 | target_include_directories(bk INTERFACE .) 5 | -------------------------------------------------------------------------------- /nbk/README.md: -------------------------------------------------------------------------------- 1 | # Maxflow with large graph support 2 | Modified version of Maxflow algorithm by Yuri Boykov and Vladimir Kolmogorov for very large graphs. Original source code availbable at http://pub.ist.ac.at/~vnk/software.html. 3 | 4 | ## Original description 5 | An implementation of the maxflow algorithm described in: 6 | 7 |
    An Experimental Comparison of Min-Cut/Max-Flow Algorithms for Energy Minimization in Computer Vision.
    8 | Yuri Boykov and Vladimir Kolmogorov.
    9 | In IEEE Transactions on Pattern Analysis and Machine Intelligence, September 2004. 10 |
11 | 12 | ## Modifications 13 | Changed to allow for very large graphs with up to 2.1 billion nodes and "any number" of edges/terms. 14 | 15 | Main changes include: 16 | - Changed edge variables to `long long`. 17 | - Changed a few other variables to `long long`. 18 | - Reduced `sizeof(node)` and `sizeof(arc)` by changing some variable types in the `struct`s. 19 | -------------------------------------------------------------------------------- /nbk/instances.inc: -------------------------------------------------------------------------------- 1 | #include "graph.h" 2 | 3 | #ifdef _MSC_VER 4 | #pragma warning(disable: 4661) 5 | #endif 6 | 7 | // Instantiations: 8 | // IMPORTANT: 9 | // flowtype should be 'larger' than tcaptype 10 | // tcaptype should be 'larger' than captype 11 | 12 | /*template class Graph; 13 | template class Graph; 14 | template class Graph; 15 | template class Graph;*/ 16 | 17 | -------------------------------------------------------------------------------- /prd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | add_library(d_maxflow_prd INTERFACE) 4 | 5 | if (WIN32) 6 | # For Windows we assume d_maxflow was built using the provided Visual Studio Solution 7 | target_link_directories(d_maxflow_prd INTERFACE lib) 8 | if (CMAKE_BUILD_TYPE MATCHES Debug) 9 | target_link_libraries(d_maxflow_prd INTERFACE d_maxflow-x64-D exttype-x64-D) 10 | else() 11 | target_link_libraries(d_maxflow_prd INTERFACE d_maxflow-x64 exttype-x64) 12 | endif() 13 | else() 14 | # For unix/linux we assume d_maxflow was build using the provided makefile 15 | target_link_directories(d_maxflow_prd INTERFACE bin/lib) 16 | target_link_libraries(d_maxflow_prd INTERFACE d_maxflow exttype) 17 | endif() 18 | target_include_directories(d_maxflow_prd INTERFACE code) 19 | -------------------------------------------------------------------------------- /prd/LICENSE.txt: -------------------------------------------------------------------------------- 1 | From https://cmp.felk.cvut.cz/~shekhovt/d_maxflow/index.html 2 | 3 | Copyright 2011 Alexander Shekhovtsov (shekhovt@fel.cvut.cz), Vaclav Hlavac (hlavac@fel.cvut.cz) 4 | 5 | There are no warranties and we take no responsibility. 6 | This version of software cannot be used for commercial purposes. 7 | Please contact the authors about other usage. 8 | -------------------------------------------------------------------------------- /prd/bin/d_maxflow/cut_cost: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/patmjen/maxflow_algorithms/85d9f258c822498e402010b5f43c3369e0754452/prd/bin/d_maxflow/cut_cost -------------------------------------------------------------------------------- /prd/code/assert.h: -------------------------------------------------------------------------------- 1 | #ifndef assert_h 2 | #define assert_h 3 | 4 | #if _MSC_VER > 1000 5 | #undef assert 6 | #ifndef NDEBUG 7 | #include 8 | #define assert(expression) {_ASSERT(expression);} 9 | #else 10 | #define assert(expression) ((void)0) 11 | #endif 12 | #else 13 | 14 | #define assert(expression) ((void)0) 15 | 16 | #endif 17 | 18 | #define check_pointer(p, beg, end) {assert(p>=beg && p tgraph; 16 | tgraph * g; 17 | public: 18 | maxflow_BK(); 19 | //depricated: 20 | //void construct(const dynamic::num_array & E, dynamic::num_array & cap, dynamic::num_array & excess); 21 | void construct(const char * filename);//!< initialize the graph from the file in DIMACS format 22 | tflow maxflow()override;//!< compute maximum flow 23 | void save_cut(const std::string & filename)override;//!< extract and save minimum cut, after maxflow is computed 24 | virtual void get_cut(int * S)override;//!< read out minimum cut, S must be allocated, S[v] \in {0,1} -- indicator if the source set of the cut 25 | virtual long long cut_cost(int * S)override;//! compute the cost if the cut S 26 | virtual long long cut_cost()override;//! verification: calculate the cost of the minimum cut, must equal the flow 27 | bool is_weak_source(int v); 28 | ~maxflow_BK(); 29 | private://temp 30 | int nV; 31 | int nE; 32 | public://! implementing dimacs_parser_callback interface 33 | virtual void allocate1(int n ,int m, int S, int T,int d,int * sz) override; 34 | virtual void allocate2(int loop) override; 35 | virtual void read_arc(int loop,int u,int v,int cap1, int cap2) override; 36 | }; 37 | 38 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/maxflow_GT.h: -------------------------------------------------------------------------------- 1 | #ifndef maxflow_GT_h 2 | #define maxflow_GT_h 3 | 4 | #include "hi_pr/hi_pr.h" 5 | #include "dimacs_parser.h" 6 | #include "maxflow_solver.h" 7 | 8 | class maxflow_GT : public maxflow_solver, public dimacs_parser_callback{ 9 | public: 10 | typedef int tcap; 11 | typedef long long tflow; 12 | public: 13 | hi_pr g; 14 | public: 15 | maxflow_GT(); 16 | void construct(const dynamic::num_array & E, dynamic::num_array & cap, dynamic::num_array & excess); 17 | tflow maxflow(); 18 | void construct(const char * filename); 19 | virtual void save_cut(const std::string & filename)override; 20 | virtual long long cut_cost()override; 21 | virtual void get_cut(int * S)override;//!< read out minimum cut, S must be allocated, S[v] \in {0,1} -- indicator if the source set of the cut 22 | public: 23 | virtual void allocate1(int n ,int m, int S, int T,int d,int * sz) override; 24 | virtual void allocate2(int loop) override; 25 | virtual void read_arc(int loop,int u,int v,int cap1, int cap2) override; 26 | }; 27 | 28 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/maxflow_HPR.cpp: -------------------------------------------------------------------------------- 1 | #include "maxflow_HPR.h" 2 | 3 | maxflow_HPR::maxflow_HPR(){ 4 | info.name = "HPR"; 5 | g.n_shifts = 4; 6 | }; 7 | 8 | maxflow_HPR::~maxflow_HPR(){ 9 | }; 10 | 11 | /* 12 | void maxflow_HPR::construct(const dynamic::num_array & E, dynamic::num_array & cap, dynamic::num_array & excess){ 13 | using namespace exttype; 14 | info.construct_t.start(); 15 | g.construct(excess.size(),E.size()[1],E.begin(),cap.begin(),excess.begin()); 16 | info.construct_t.stop(); 17 | }; 18 | */ 19 | 20 | maxflow_HPR::tflow maxflow_HPR::maxflow(){ 21 | info.solve_t.start(); 22 | g.global_update(); 23 | g.stageOne(true); 24 | info.flow = g.flow; 25 | g.global_update();//required to get the minimum cut 26 | info.solve_t.stop(); 27 | info.nV = g.n; 28 | info.nE = g.m/2; 29 | info.mem_shared = dynamic::memserver::get_al_blocks().mem_used(); 30 | return info.flow; 31 | }; 32 | 33 | void maxflow_HPR::construct(const char * filename){ 34 | info.construct_t.start(); 35 | dimacs_parser(filename,*this,2); 36 | info.construct_t.stop(); 37 | }; 38 | 39 | void maxflow_HPR::allocate1(int n ,int m, int S, int T,int d,int * sz){ 40 | g.allocate1(n,0,m,0,0,0,S,T); 41 | g.reset_counters(); 42 | this->S = S; 43 | this->T = T; 44 | }; 45 | 46 | void maxflow_HPR::allocate2(int loop){ 47 | if(loop==0){ 48 | g.allocate2(); 49 | g.reset_counters(); 50 | }; 51 | }; 52 | 53 | void maxflow_HPR::read_arc(int loop,int u,int v,int cap1, int cap2){ 54 | g.add_edge(u,v,cap1,cap2,loop); 55 | }; 56 | 57 | tflow maxflow_HPR::cut_cost(){ 58 | return g.cut_cost(); 59 | }; 60 | 61 | void maxflow_HPR::get_cut(int * C){ 62 | for(int v=0;v & E, dynamic::num_array & cap, dynamic::num_array & excess); 21 | tflow maxflow(); 22 | void construct(const char * filename); 23 | void save_cut(const std::string & filename)override{}; 24 | virtual tflow cut_cost()override; 25 | virtual void get_cut(int * S)override; 26 | public: 27 | virtual void allocate1(int n ,int m, int S, int T,int d,int * sz)override; 28 | virtual void allocate2(int loop)override; 29 | virtual void read_arc(int loop,int u,int v,int cap1, int cap2)override; 30 | }; 31 | 32 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/maxflow_solver.h: -------------------------------------------------------------------------------- 1 | #ifndef maxflow_solver_h 2 | #define maxflow_solver_h 3 | 4 | #include "debug/performance.h" 5 | #include "dynamic/dynamic.h" 6 | #include "debug/logs.h" 7 | 8 | class maxflow_solver{ 9 | public: 10 | //dynamic::fixed_array1 info; 11 | struct tinfo{ 12 | int nV; 13 | int nE; 14 | int nBE; 15 | std::string name; 16 | long long flow; 17 | int sweeps; 18 | debug::PerformanceCounter construct_t; 19 | debug::PerformanceCounter solve_t; 20 | debug::PerformanceCounter msg_t; 21 | debug::PerformanceCounter augment_t; 22 | debug::PerformanceCounter relabel_t; 23 | debug::PerformanceCounter gap_t; 24 | debug::PerformanceCounter diskr_t; 25 | debug::PerformanceCounter diskw_t; 26 | size_t mem_shared; 27 | size_t mem_region; 28 | long long diskr_b; 29 | long long diskw_b; 30 | }info; 31 | // 32 | struct tparams{ 33 | int n_threads; 34 | }params; 35 | protected: 36 | int S,T; 37 | public: 38 | typedef int tcap; 39 | typedef long long tflow; 40 | public: 41 | maxflow_solver(); 42 | virtual ~maxflow_solver(){}; 43 | virtual tflow maxflow()=0; 44 | void print_info();//const char * file, bool append = false); 45 | virtual void save_cut(const std::string & filename)=0; 46 | virtual void get_cut(int * S){}; 47 | virtual tflow cut_cost(int * S){return 0;}; 48 | virtual tflow cut_cost(){return 0;}; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /prd/code/d_maxflow/parallel_ARD1.h: -------------------------------------------------------------------------------- 1 | #ifndef parallel_ARD1_h 2 | #define parallel_ARD1_h 3 | 4 | #include "parallel_discharge.h" 5 | #include "stream_ARD1.h" 6 | 7 | class parallel_ARD1 : public stream_ARD1, public parallel_discharge{ 8 | public: 9 | typedef stream_ARD1 parent; 10 | private: 11 | void hist_dec(int sweep,int r)override; 12 | void hist_inc(int sweep,int r)override; 13 | public: 14 | parallel_ARD1(); 15 | void construct(region_graph * G); 16 | }; 17 | 18 | /* 19 | class parallel_ARD1 : public stream_ARD1{ 20 | public: 21 | typedef stream_ARD1 parent; 22 | private: 23 | void fuse_flow(); 24 | void hist_dec(int sweep,int r)override; 25 | void hist_inc(int sweep,int r)override; 26 | //void msg_out(int sweep, int r); 27 | //void process_region(int sweep, int r); 28 | //void lock_in_msg(int r); 29 | //void unlock_in_msg(int r); 30 | //void lock_out_msg(int r); 31 | //void unlock_out_msg(int r); 32 | void lock_msg(int r); 33 | void unlock_msg(int r); 34 | public: 35 | parallel_ARD1(); 36 | void construct(region_graph * G); 37 | tflow maxflow()override; 38 | }; 39 | */ 40 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/parallel_PRD.cpp: -------------------------------------------------------------------------------- 1 | #include "parallel_PRD.h" 2 | 3 | #include "parallel_discharge.cpp" 4 | template class parallel_discharge; 5 | 6 | void parallel_PRD::construct(region_graph * G){ 7 | parent::construct(G,false); 8 | }; 9 | 10 | parallel_PRD::parallel_PRD(){ 11 | info.name = "P-PRD"; 12 | }; 13 | 14 | void parallel_PRD::hist_dec(int sewwp, int r){ 15 | //#pragma omp critical 16 | { 17 | //subtract r from global label hist 18 | for(int v=0;vnV;++v){//go over inner vertices 19 | int d = R[r]->g->nodes[v].d; 20 | if(dnV;++v){//go over inner vertices 33 | int d = R[r]->g->nodes[v].d; 34 | if(d{ 8 | public: 9 | typedef stream_PRD parent; 10 | private: 11 | void hist_dec(int sweep,int r)override; 12 | void hist_inc(int sweep,int r)override; 13 | public: 14 | parallel_PRD(); 15 | void construct(region_graph * G); 16 | }; 17 | 18 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/parallel_discharge.h: -------------------------------------------------------------------------------- 1 | #ifndef parallel_discharge_h 2 | #define parallel_discharge_h 3 | 4 | #include "sequential_discharge.h" 5 | 6 | template class parallel_discharge : virtual public sequential_discharge{ 7 | public: 8 | typedef sequential_discharge parent; 9 | typedef typename parent::tflow tflow; 10 | using parent::info; 11 | using parent::G; 12 | using parent::dead; 13 | using parent::dead0; 14 | using parent::nractive; 15 | using parent::flow; 16 | using parent::d_inf; 17 | using parent::n_relabelled; 18 | using parent::preprocess; 19 | private: 20 | void fuse_flow(); 21 | void lock_msg(int r); 22 | void unlock_msg(int r); 23 | exttype::intf active; 24 | public: 25 | tflow maxflow()override; 26 | }; 27 | 28 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/region_discharge.cpp: -------------------------------------------------------------------------------- 1 | #include "region_discharge.h" 2 | 3 | bool region_discharge::is_boundary(int v)const{ 4 | return v{ 4 | }; 5 | 6 | template class seed_buckets; -------------------------------------------------------------------------------- /prd/code/d_maxflow/sequential_discharge.h: -------------------------------------------------------------------------------- 1 | #ifndef sequential_discharge_h 2 | #define sequential_discharge_h 3 | 4 | #include "defs.h" 5 | #include "exttype/fixed_vect.h" 6 | #include "region_graph.h" 7 | #include "maxflow_solver.h" 8 | 9 | //using namespace dynamic; 10 | 11 | template class sequential_discharge : public maxflow_solver{ 12 | protected: 13 | dynamic::page_allocator page1; 14 | public: 15 | typedef int tcap; 16 | typedef long long tflow; 17 | public://input 18 | region_graph * G; 19 | bool unload; 20 | public: 21 | dynamic::fixed_array1 R;//!< region networks, aligned with nodes of G 22 | public: 23 | tflow flow; 24 | int d_inf; 25 | int d_min; 26 | protected: 27 | exttype::intf d_hist; 28 | int nractive; 29 | int nrchanged; 30 | long long dead; 31 | long long dead0; 32 | bool some_active; 33 | bool preprocess; 34 | int n_relabelled; 35 | const char * tmp_pth; 36 | public: 37 | sequential_discharge(); 38 | virtual ~sequential_discharge(); 39 | void construct(region_graph * G, bool unload = true); 40 | void set_tmp(const char * tmp_pth); 41 | protected: 42 | virtual void init(); 43 | void construct_region(int r); 44 | void load_region(int r); 45 | void unload_region(int r); 46 | void msg_in(int sweep, int r); 47 | void msg_out(int sweep, int r); 48 | virtual void global_gap(); 49 | virtual void process_region(int sweep, int r, bool flow_optimal); 50 | virtual void hist_inc(int sweep,int r); 51 | virtual void hist_dec(int sweep, int r); 52 | virtual void global_heuristic(){}; 53 | virtual void flow_is_maximum(){}; 54 | public: 55 | tflow maxflow()override; 56 | void save_cut(const std::string & filename)override; 57 | void get_cut(int * C)override; 58 | virtual long long cut_cost()override; 59 | void check_validity(); 60 | }; 61 | 62 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/stream_ARD1.h: -------------------------------------------------------------------------------- 1 | #ifndef stream_ARD1_h 2 | #define stream_ARD1_h 3 | 4 | #include "sequential_discharge.h" 5 | #include "seed_BK1.h" 6 | 7 | class stream_ARD1 : virtual public sequential_discharge{ 8 | public: 9 | typedef sequential_discharge parent; 10 | public: 11 | stream_ARD1(); 12 | void init(); 13 | void hist_dec(int sweep, int r)override; 14 | void hist_inc(int sweep,int r)override; 15 | void global_gap()override; 16 | void process_region(int sweep, int r, bool flow_optimal)override; 17 | //void apply_gap(int r); 18 | //void initial_LB(); 19 | public://boundary relabel heuristic 20 | dynamic::fixed_array1 groups_pool;// at most nB elements 21 | dynamic::fixed_array1 g_cache; // at most d_inf elements 22 | region_graph::d_group* g_free; 23 | void global_heuristic()override;//!< boundary relabel heuristic 24 | }; 25 | 26 | #endif -------------------------------------------------------------------------------- /prd/code/d_maxflow/stream_PRD.h: -------------------------------------------------------------------------------- 1 | #ifndef stream_PRD_h 2 | #define stream_PRD_h 3 | 4 | #include "PRD.h" 5 | #include "sequential_discharge.h" 6 | 7 | class stream_PRD : virtual public sequential_discharge{ 8 | public: 9 | typedef sequential_discharge parent; 10 | public: 11 | stream_PRD(); 12 | void init(); 13 | void hist_dec(int sweep, int r); 14 | void hist_inc(int sweep,int r); 15 | void global_gap(); 16 | void process_region(int sweep, int r, bool flow_optimal); 17 | bool non_empty_gap(int r); 18 | virtual void flow_is_maximum()override; 19 | }; 20 | 21 | /* 22 | #include "region_graph.h" 23 | #include "maxflow_solver.h" 24 | 25 | using namespace dynamic; 26 | 27 | class stream_PRD : public maxflow_solver{ 28 | private: 29 | dynamic::page_allocator page; 30 | public: 31 | typedef int tcap; 32 | typedef long long tflow; 33 | public: 34 | region_graph & G; 35 | dynamic::fixed_array1 R;//!< region networks, aligned with nodes of G 36 | public: 37 | tflow flow; 38 | int d_inf; 39 | intf d_hist; 40 | bool unload; 41 | int global_gap; 42 | public: 43 | stream_PRD(region_graph & _G, bool unload=true); 44 | ~stream_PRD(); 45 | void construct(); 46 | public: 47 | tflow maxflow()override; 48 | void save_cut(const std::string & filename)override{}; 49 | virtual long long cut_cost()override; 50 | private: 51 | //void check_incoming_flow(int r);//check for messages with non-zero flow 52 | }; 53 | */ 54 | 55 | #endif -------------------------------------------------------------------------------- /prd/code/data/dataset.cpp: -------------------------------------------------------------------------------- 1 | #include "dataset.h" 2 | 3 | namespace dynamic{ 4 | void test(){ 5 | mint3 CC; 6 | CC[0] = 0; 7 | CC << 0; 8 | geom::DataSetTopology<3> topology3; 9 | geom::DataSetTopology<3>::nb_iterator nbit1(mint3(0,0,0),mint3(10,10,10)); 10 | geom::DataSetTopology<3>::dir_edge_iterator eit(mint3(10,10,10)); 11 | //geom::DataSetTopology<3>::ndir_edge_iterator neit(mint3(10,10,10)); 12 | //++neit; 13 | DataSet data1 (mint2(5,5),0); 14 | data1[mint2(0,0)]; 15 | DataSet data2 (mint2(5,5),0); 16 | data2[mint2(0,0)]; 17 | }; 18 | }; -------------------------------------------------------------------------------- /prd/code/debug/except.h: -------------------------------------------------------------------------------- 1 | #ifndef debug_except_h 2 | #define debug_except_h 3 | 4 | #undef _SCL_SECURE_NO_WARNINGS 5 | #undef _CRT_SECURE_NO_WARNINGS 6 | 7 | #define _SCL_SECURE_NO_WARNINGS 1 8 | #define _CRT_SECURE_NO_WARNINGS 1 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "assert.h" 15 | //#include "dynamic/mallocator.h" 16 | 17 | //typedef std::basic_string,mallocator > dstring; 18 | typedef std::string dstring; 19 | class debug_exception : public std::exception{ 20 | private: 21 | //const char * pmsg; 22 | dstring smsg; 23 | void halt(){ 24 | fprintf(stderr,"Error: %s\n",smsg.c_str()); 25 | exit(1); 26 | }; 27 | public: 28 | debug_exception():smsg("unspecified"){ 29 | assert(false); 30 | }; 31 | 32 | debug_exception(const char * msg):smsg(msg){ 33 | halt(); 34 | }; 35 | debug_exception(const dstring & msg):smsg(msg){ 36 | halt(); 37 | }; 38 | debug_exception(const debug_exception & x):smsg(x.smsg){ 39 | halt(); 40 | }; 41 | virtual ~debug_exception() throw (){}; 42 | public: 43 | virtual const char *what( ) const throw( ){ 44 | return smsg.c_str(); 45 | }; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /prd/code/debug/logs.cpp: -------------------------------------------------------------------------------- 1 | #include "logs.h" 2 | #include "files/xfs.h" 3 | 4 | 5 | namespace debug{ 6 | using namespace txt; 7 | stdoutStream stdoutStream::the_stream; 8 | //pTextStream stream; 9 | //pTextStream errstream; 10 | pTextStream out1(new txt::TabbedTextStream(txt::FileStream("log/out1.txt",false)),true); 11 | pTextStream stream(new txt::TabbedTextStream(txt::EchoStream(txt::FileStream("log/output.txt",false),stdoutStream::the_stream)),true); 12 | pTextStream errstream(new txt::TabbedTextStream(txt::EchoStream(txt::FileStream("log/errors.log",false),stdoutStream::the_stream)),true); 13 | bool debug1=0; 14 | }; -------------------------------------------------------------------------------- /prd/code/debug/logs.h: -------------------------------------------------------------------------------- 1 | #ifndef debug_logs_h 2 | #define debug_logs_h 3 | 4 | #include "streams/xstringstream.h" 5 | //#include 6 | #include 7 | 8 | 9 | namespace debug{ 10 | using namespace txt; 11 | 12 | //_________________stdout_________________________ 13 | class stdoutStream : public TextStream{ 14 | public: 15 | virtual TextStream & write(const char * x){ 16 | std::cout< 5 | 6 | namespace debug{ 7 | CRTREPORTMODE::CRTREPORTMODE(){ 8 | #if defined(_DEBUG) 9 | //#error Requires Multythreaded Debug Runtime Library 10 | #endif 11 | _CrtSetReportMode(_CRT_ERROR,_CRTDBG_MODE_FILE); 12 | _CrtSetReportFile(_CRT_ERROR,_CRTDBG_FILE_STDOUT); 13 | int tmp; 14 | tmp = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); 15 | tmp = tmp | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF; 16 | _CrtSetDbgFlag(tmp); 17 | }; 18 | 19 | CRTREPORTMODE::~CRTREPORTMODE(){ 20 | int tmp = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); 21 | if(!(tmp & _CRTDBG_LEAK_CHECK_DF))_CrtDumpMemoryLeaks(); 22 | }; 23 | 24 | CRTREPORTMODE CrtReportMode; 25 | }; 26 | #else 27 | namespace debug{ 28 | CRTREPORTMODE::CRTREPORTMODE(){ 29 | }; 30 | CRTREPORTMODE::~CRTREPORTMODE(){ 31 | }; 32 | }; 33 | #endif 34 | -------------------------------------------------------------------------------- /prd/code/debug/msvcdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef msvc_debug_h 2 | #define msvc_debug_h 3 | 4 | namespace debug{ 5 | class CRTREPORTMODE{ 6 | public: 7 | CRTREPORTMODE(); 8 | ~CRTREPORTMODE(); 9 | }; 10 | extern CRTREPORTMODE CrtReportMode; 11 | }; 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /prd/code/debug/performance.h: -------------------------------------------------------------------------------- 1 | #ifndef performance_h 2 | #define performance_h 3 | 4 | namespace debug{ 5 | class PerformanceCounter{ 6 | private: 7 | long long t1; 8 | long long Dt; 9 | bool counting; 10 | public: 11 | PerformanceCounter(); 12 | void start(); 13 | long long tickcount()const; 14 | double time()const; 15 | void pause(); 16 | void resume(); 17 | void stop(); 18 | }; 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /prd/code/defs.h: -------------------------------------------------------------------------------- 1 | #ifndef defs_h 2 | #define defs_h 3 | 4 | #if _MSC_VER > 1000 5 | #else// not msvc 6 | #define __forceinline inline 7 | #define override 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /prd/code/dynamic/array_allocator.h: -------------------------------------------------------------------------------- 1 | #ifndef array_allocator_h 2 | #define array_allocator_h 3 | 4 | #include "block_allocator.h" 5 | #include 6 | 7 | namespace dynamic{ 8 | //________________________array_allocator________________________ 9 | //! Implementation of std::allocator for allocation on the block_allocator::global 10 | template class array_allocator{ 11 | public: 12 | typedef int size_type; 13 | typedef int difference_type; 14 | typedef T *pointer; 15 | typedef const T *const_pointer; 16 | typedef T& reference; 17 | typedef const T& const_reference; 18 | typedef T value_type; 19 | pointer address(reference x) const{return &x;}; 20 | const_pointer address(const_reference x) const{return &x;}; 21 | public: 22 | //default constructor 23 | //default copy constructor 24 | //default operator = 25 | public: 26 | pointer allocate(size_type n, const void *hint=0){ 27 | long long size_bytes = sizeof(T)*(long long)(n); 28 | if(size_bytes>std::numeric_limits::max()){ 29 | dynamic::memserver::error_allocate(size_bytes); 30 | }; 31 | void * P = memserver::get_global()->allocate(size_t(size_bytes)); 32 | return (T*)P; 33 | }; 34 | 35 | void deallocate(pointer x, size_type n){ 36 | memserver::get_global()->deallocate((char*)x); 37 | }; 38 | 39 | void construct(pointer p){ 40 | new ((void *)p) T(); 41 | }; 42 | 43 | void construct(pointer p, const T & val){ 44 | new ((void *)p) T(val); 45 | }; 46 | 47 | void destroy(pointer p){ 48 | p->~T(); 49 | }; 50 | 51 | size_type max_size() const{ 52 | return 0; 53 | }; 54 | public: 55 | template struct rebind{ 56 | typedef array_allocator other; 57 | }; 58 | }; 59 | }; 60 | #endif 61 | -------------------------------------------------------------------------------- /prd/code/dynamic/dynamic.h: -------------------------------------------------------------------------------- 1 | #include "fixed_array1.h" 2 | #include "fixed_array2.h" 3 | #include "data/dataset.h" 4 | #include "dynamic/num_array.h" 5 | -------------------------------------------------------------------------------- /prd/code/dynamic/mallocator.h: -------------------------------------------------------------------------------- 1 | #ifndef mallocator_h 2 | #define mallocator_h 3 | 4 | /*! mallocator - implements std::allocator using malloc 5 | used for low-level allocation 6 | */ 7 | //________________________array_allocator________________________ 8 | //! Implementation of std::allocator for allocation on the block_allocator::global 9 | template class mallocator{ 10 | public: 11 | typedef int size_type; 12 | typedef int difference_type; 13 | typedef T *pointer; 14 | typedef const T *const_pointer; 15 | typedef T& reference; 16 | typedef const T& const_reference; 17 | typedef T value_type; 18 | pointer address(reference x) const{return &x;}; 19 | const_pointer address(const_reference x) const{return &x;}; 20 | public: 21 | //default constructor 22 | //default copy constructor 23 | //default operator = 24 | public: 25 | pointer allocate(size_type n, const void *hint=0){ 26 | void * P = malloc(n*sizeof(T)); 27 | return (T*)P; 28 | }; 29 | 30 | void deallocate(pointer x, size_type n){ 31 | assert(x!=0); 32 | free(x); 33 | }; 34 | 35 | void construct(pointer p){ 36 | new ((void *)p) T(); 37 | }; 38 | 39 | void construct(pointer p, const T & val){ 40 | new ((void *)p) T(val); 41 | }; 42 | 43 | void destroy(pointer p){ 44 | p->~T(); 45 | }; 46 | 47 | size_type max_size() const{ 48 | return 0; 49 | }; 50 | public: 51 | template struct rebind{ 52 | typedef mallocator other; 53 | }; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /prd/code/dynamic/num_array.cpp: -------------------------------------------------------------------------------- 1 | #include "num_array.h" 2 | 3 | -------------------------------------------------------------------------------- /prd/code/exttype/exttype.h: -------------------------------------------------------------------------------- 1 | #include "arrays.h" 2 | #include "fixed_vect.h" 3 | #include "ivector.h" 4 | #include "itern.h" 5 | #include "pvect.h" 6 | -------------------------------------------------------------------------------- /prd/code/exttype/fixed_vect.h: -------------------------------------------------------------------------------- 1 | #ifndef fixed_vect_h 2 | #define fixed_vect_h 3 | 4 | #include "dynamic/fixed_array1.h" 5 | #include "ivector.h" 6 | 7 | namespace exttype{ 8 | template class fixed_vect : public ivector, dynamic::fixed_array1 > >{ 9 | private: 10 | typedef ivector > > parent; 11 | public: 12 | int count()const{return this->size();}; 13 | fixed_vect(){}; 14 | explicit fixed_vect(int K){// constructor with initialization 15 | this->resize(K); 16 | for(int i=0;isize();++i)(*this)[i] = 0; 17 | }; 18 | explicit fixed_vect(int n, const type v0,...){ 19 | this->resize(n); 20 | (*this)[0] = v0; 21 | va_list a; 22 | va_start(a,v0); 23 | for(int i=1;i charf; 36 | typedef fixed_vect intf; 37 | typedef fixed_vect doublef; 38 | typedef fixed_vect floatf; 39 | 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /prd/code/exttype/key_less.h: -------------------------------------------------------------------------------- 1 | #ifndef key_less_h 2 | #define key_less_h 3 | 4 | template 5 | struct key_less{ 6 | key_less(key_type* _key_beg):key_beg(_key_beg){}; 7 | key_type* key_beg; 8 | bool operator()( 9 | const key_type & _Left, 10 | const key_type & _Right 11 | )const{ 12 | return key_beg[_Left] 17 | struct key_gt{ 18 | key_gt(key_type* _key_beg):key_beg(_key_beg){}; 19 | key_type* key_beg; 20 | bool operator()( 21 | const key_type & _Left, 22 | const key_type & _Right 23 | )const{ 24 | return key_beg[_Left]>key_beg[_Right]; 25 | }; 26 | }; 27 | 28 | #endif -------------------------------------------------------------------------------- /prd/code/exttype/minmax.h: -------------------------------------------------------------------------------- 1 | #ifndef minmax_h 2 | #define minmax_h 3 | 4 | #define NOMINMAX 5 | 6 | #include 7 | 8 | #ifdef max 9 | #undef max 10 | #endif 11 | #ifdef min 12 | #undef min 13 | #endif 14 | namespace exttype{ 15 | template T min(const T & a, const T & b){ 16 | return a<=b?a:b; 17 | }; 18 | template T max(const T & a, const T & b){ 19 | return a>=b?a:b; 20 | }; 21 | template T min(const T & a, const T & b, const T & c){ 22 | return (min(min(a,b),c)); 23 | }; 24 | template T max(const T & a, const T & b, const T & c){ 25 | return (max(max(a,b),c)); 26 | }; 27 | 28 | }; 29 | #endif 30 | -------------------------------------------------------------------------------- /prd/code/exttype/pvect.cpp: -------------------------------------------------------------------------------- 1 | #include "pvect.h" 2 | 3 | namespace geom{ 4 | 5 | }; 6 | -------------------------------------------------------------------------------- /prd/code/exttype/pvect.h: -------------------------------------------------------------------------------- 1 | #ifndef geom_pvect_h 2 | #define geom_pvect_h 3 | 4 | #include "exttype/ivector.h" 5 | #include "exttype/itern.h" 6 | #include "exttype/intn.h" 7 | 8 | #include "dynamic/buffer.h" 9 | 10 | namespace exttype{ 11 | //_________________________pvect_________________________________________________ 12 | template class pvect; 13 | 14 | template struct pvect_binder{ 15 | typedef typename dynamic::ref_buffer container; 16 | typedef ivector, container> base; 17 | }; 18 | 19 | template class pvect : public pvect_binder::base{ 20 | public: 21 | typedef typename pvect_binder::container container; 22 | typedef typename pvect_binder::base parent; 23 | private: 24 | //! forbidden 25 | pvect cpy()const{return pvect();}; 26 | public: 27 | pvect(field * x, int n){ 28 | this->set_ref(x,n); 29 | }; 30 | //template