给定一个有向图,我需要找到从中可以得出所有其他顶点的最小顶点集。
因此,函数的结果应该是最小数量的顶点,通过遵循有向边可以从中获得所有其他顶点。
可能的最大结果是没有边缘,因此将返回所有节点。
如果图形中有周期,则为每个周期选择一个节点。哪一个无关紧要,但是如果再次运行该算法,则应该保持一致。
我不确定是否存在现有的算法吗?如果有,它有名字吗?我已经尝试进行研究,而最接近的事情似乎是找到母顶点。 如果是该算法,那么可以详细说明实际算法,因为该链接中给出的答案有点含糊。
鉴于我必须在javascript中实现此功能,因此首选项将是.js库或javascript示例代码。
我对Ninject有问题.
我的约束规则:
this.Bind<ISphinxQLServer>().To<SQLServer>();
this.Bind<IMySQLServer>().To<SQLServer>();
this.Bind<ISQLLogger>().To<StandardSQLLogger>()
.InRequestScope();
this.Bind<DatabaseConnections>()
.ToMethod(x => ConnectionFactory.GetConnections())
.InRequestScope();
this.Bind<SQLServer>().ToSelf()
.InRequestScope()
.WithConstructorArgument("connections", Kernel.Get<DatabaseConnections>())
.WithConstructorArgument("logger", Kernel.Get<ISQLLogger>());
Run Code Online (Sandbox Code Playgroud)
哪里
SQLServer,ISphinxQLServer和IMySQLServer是:
public class SQLServer: ISphinxQLServer, IMySQLServer
{
public DatabaseConnections Connections { get; internal set; }
public ISQLLogger Logger { get; internal set; }
public SQLServer(DatabaseConnections connections)
{
this.Connections = connections;
}
public SQLServer(DatabaseConnections connections, ISQLLogger logger)
{
this.Connections = connections;
this.Logger = logger;
}
}
Run Code Online (Sandbox Code Playgroud)
我希望每个用户请求到我的asp.net mvc站点创建一个SQLServer,一个ISQLLogger和一个DatabaseConnections.但我的解决方案不起作用.我究竟做错了什么?=(
我正在尝试分析调用其他函数的函数.我将分析器称为如下:
from mymodule import foo
def start():
# ...
foo()
import cProfile as profile
profile.run('start()', output_file)
p = pstats.Stats(output_file)
print "name: "
print p.sort_stats('name')
print "all stats: "
p.print_stats()
print "cumulative (top 10): "
p.sort_stats('cumulative').print_stats(10)
Run Code Online (Sandbox Code Playgroud)
我发现分析器说所有的时间都花在mymodule的函数"foo()"上,而不是把它放到子函数foo()调用中,这就是我想要看到的.如何让分析器报告这些功能的性能?
谢谢.
我需要在我的Kohana 3应用程序中实现openID身份验证.我正在搜索并找到这个http://code.google.com/p/kohanamodules/wiki/Openid#whb,但这是针对2.x版本的kohana,不能在3.x中使用.有没有实现?
我修改了一个程序,它现在需要更多的参数.如何找到调用该过程的每个位置,以便更新proc传递的参数个数?
我试过这个:
select * from syscomments where text like '%MODIFIED-PROCEDURE-NAME%'
Run Code Online (Sandbox Code Playgroud)
但我仍然发现其他地方的proc被称为此查询没有返回.
有没有办法可以更改按钮颜色并保留Windows VisualStyle?我想创建一个看起来像checkBox2(颜色和样式)的按钮

this.button2.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
this.button2.UseVisualStyleBackColor = false; //if true, BackColor gets ignored
Run Code Online (Sandbox Code Playgroud) 我想知道如何将回调函数的第一个参数设置为我想要的,就像jquery在成功回调或完整回调中所做的那样
我想做这个:
$.ajax({
success: function(data) {
alert(data)
}
});
Run Code Online (Sandbox Code Playgroud)
根据我的理解,这就像我能达到我想要的那样接近
function test(text) {
this.text = text
this.success = function(this.text) { }
}
var a = new test('King Kong')
a.success = function(k){
alert(k)
}
Run Code Online (Sandbox Code Playgroud)
我希望警报说"金刚"
是否有一些指南描述了PHP的内部结构?
从完整网址中提取基本网址的快速方法?例如,如果我有http://test.example.com/abcd/test.html - 我只想http://test.example.com.
我总是可以进行字符串解析 - 但是想知道Uri中是否有东西我可以直接获取它.
众所周知,arraylist init.应该是这样的
ArrayList<A> a = new ArrayList<A>();
ArrayList<Integer> a = new ArrayList<Number>(); // compile-time error
Run Code Online (Sandbox Code Playgroud)
所以,为什么java允许这些?
1. ArrayList<? extends Object> a1 = new ArrayList<Object>();
2. ArrayList<?> a2 = new ArrayList<Integer>();
Run Code Online (Sandbox Code Playgroud)
那么,如果他们是正确的,为什么不允许这些呢?
1. a1.add(3);
2. a2.add(3);
Run Code Online (Sandbox Code Playgroud)
编译器消息是:类型ArrayList中的方法add(int,capture#1-of?extends Object)不适用于参数(int)
更一般
1. a1.add(null e);
2. a2.add(? e);
Run Code Online (Sandbox Code Playgroud)
我读到了这个,但很高兴收到你的来信.谢谢
另一个有趣的观点是:
ArrayList<ArrayList<?>> a = new ArrayList<ArrayList<?>>(); // correct
ArrayList<?> a = new ArrayList<?>(); // wrong. I know it's reason but I have some
question in my mind that mentioned above
Run Code Online (Sandbox Code Playgroud) algorithm ×1
android ×1
arraylist ×1
asp.net-mvc ×1
c# ×1
callback ×1
cprofile ×1
generics ×1
graph-theory ×1
internals ×1
java ×1
javascript ×1
kohana-3 ×1
ninject ×1
openid ×1
php ×1
profiler ×1
python ×1
sql-server ×1